{"id":85,"date":"2011-10-29T14:28:47","date_gmt":"2011-10-29T13:28:47","guid":{"rendered":"\/site\/?p=85"},"modified":"2024-02-23T11:34:21","modified_gmt":"2024-02-23T10:34:21","slug":"perl-internal-server-error-suexec","status":"publish","type":"post","link":"\/site\/2011\/10\/perl-internal-server-error-suexec\/","title":{"rendered":"Perl &#8211; Internal Server Error &#8211; suexec"},"content":{"rendered":"<p>Even a simple script gives me this error. Here&#8217;s my simple script:<br \/>\ncat test.cgi<\/p>\n<blockquote><p>#!\/usr\/bin\/perl<br \/>\nuse strict;<br \/>\nuse warnings;<br \/>\nprint &#8220;Content-type: text\/plain\\n\\n&#8221;;<br \/>\nprint &#8220;Hello, World&#8221;;<\/p><\/blockquote>\n<p>Lets start with three lines of my logfile:<\/p>\n<blockquote><p>suexec failure: could not open log file<br \/>\nfopen: No such file or directory<br \/>\nPremature end of script headers: test.cgi<\/p><\/blockquote>\n<p>So, first thing to look at is suexec, apparently it is not able to open it&#8217;s logfile. At runtime there is now way to change the settings of suexec. To see the compile-time settings of suexec use: <br \/>suexec -V<\/p>\n<blockquote><p> -D AP_DOC_ROOT=&#8221;\/var\/www&#8221;<br \/>\n -D AP_GID_MIN=500<br \/>\n -D AP_HTTPD_USER=&#8221;nobody&#8221;<br \/>\n -D AP_LOG_EXEC=&#8221;\/var\/log\/httpd\/suexec&#8221;<br \/>\n -D AP_SAFE_PATH=&#8221;\/usr\/local\/bin:\/usr\/bin:\/bin&#8221;<br \/>\n -D AP_UID_MIN=500<br \/>\n -D AP_USERDIR_SUFFIX=&#8221;public_html&#8221;\n<\/p><\/blockquote>\n<p>It turned out there was no \/var\/log\/httpd directory, so there was nog suexec-log. (No, my setup is not default&#8230;) After creating the \/var\/log\/httpd-directory and accessing my test.cgi, the logfile was created, but&#8230;<\/p>\n<p>There appared a line in my apache-logfiles: <\/p>\n<blockquote><p>(13)Permission denied: access to \/cgi-bin\/test.cgi denied<\/p><\/blockquote>\n<p>Luckely a had a suexec-logfile by now, telling me: <\/p>\n<blockquote><p>user mismatch (daemon instead of nobody)<\/p><\/blockquote>\n<p>Meaning: Apache is running as the user daemon, while the default seams to be nobody.<br \/>\nSo, at the end I recompiled Apache using: <\/p>\n<blockquote><p><font face=courier>CFLAGS= &#45;O3 &#45;march=core2 &#45;pipe &#45;O3 &#45;march=core2 &#45;pipe &#45;O3 \\<br \/> &nbsp; &nbsp; &nbsp; &nbsp; &#45;march=core2 &#45;pipe<br \/>\nOPTS= &#45;&#45;prefix=\/etc\/httpd &#45;&#45;sysconfdir=\/etc\/httpd\/conf &#45;&#45;exec&#45;prefix=\/usr &#45;&#45;sbindir=\/usr\/sbin &#45;&#45;libexecdir=\/usr\/libexec\/httpd\/modules &#45;&#45;datadir=\/var\/www &#45;&#45;sharedstatedir=\/var\/run\/httpd &#45;&#45;localstatedir=\/var &#45;&#45;libdir=\/usr\/lib &#45;&#45;includedir=\/usr\/include\/httpd &#45;&#45;infodir=\/usr\/share\/info &#45;&#45;mandir=\/usr\/share\/man &#45;&#45;enable&#45;so &#45;&#45;enable&#45;rewrite &#45;&#45;enable&#45;mime&#45;magic &#45;&#45;enable&#45;exception&#45;hook &#45;&#45;enable&#45;layout=GNU &#45;&#45;enable&#45;usertrack &#45;&#45;with&#45;apr=\/usr &#45;&#45;with&#45;apr&#45;util=\/usr &#45;&#45;with&#45;berkeley&#45;db &#45;&#45;with&#45;gdbm &#45;&#45;enable&#45;ssl &#45;&#45;enable&#45;proxy &#45;&#45;enable&#45;proxy&#45;connect &#45;&#45;enable&#45;proxy&#45;http &#45;&#45;enable&#45;proxy&#45;ftp &#45;&#45;enable&#45;suexec &#45;&#45;with&#45;suexec &#45;&#45;with&#45;suexec&#45;caller=daemon &#45;&#45;with&#45;suexec&#45;docroot=\/home &#45;&#45;with&#45;suexec&#45;logfile=\/var\/log\/httpd\/suexec &#45;&#45;with&#45;suexec&#45;bin=\/usr\/sbin\/suexec &#45;&#45;with&#45;suexec&#45;uidmin=500 &#45;&#45;with&#45;suexec&#45;gidmin=500 &#45;&#45;enable&#45;cgid &#45;&#45;with&#45;mpm=prefork<\/font><\/p><\/blockquote>\n<p>Since my suexec-docroot is somewhere else (not \/var\/www), notice there is a &#8220;&#45;&#45;with&#45;suexec&#45;docroot=\/home&#8221;<\/p>\n<p>Hope this helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Even a simple script gives me this error. Here&#8217;s my simple script: cat test.cgi #!\/usr\/bin\/perl use strict; use warnings; print &#8220;Content-type: text\/plain\\n\\n&#8221;; print &#8220;Hello, World&#8221;; Lets start with three lines of my logfile: suexec failure: could not open log file fopen: No such file or directory Premature end of script headers: test.cgi So, first thing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"\/site\/wp-json\/wp\/v2\/posts\/85"}],"collection":[{"href":"\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/site\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":27,"href":"\/site\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":113,"href":"\/site\/wp-json\/wp\/v2\/posts\/85\/revisions\/113"}],"wp:attachment":[{"href":"\/site\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/site\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"\/site\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}