Even a simple script gives me this error. Here’s my simple script:
cat test.cgi
#!/usr/bin/perl
use strict;
use warnings;
print “Content-type: text/plain\n\n”;
print “Hello, World”;
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 to look at is suexec, apparently it is not able to open it’s logfile. At runtime there is now way to change the settings of suexec. To see the compile-time settings of suexec use:
suexec -V
-D AP_DOC_ROOT=”/var/www”
-D AP_GID_MIN=500
-D AP_HTTPD_USER=”nobody”
-D AP_LOG_EXEC=”/var/log/httpd/suexec”
-D AP_SAFE_PATH=”/usr/local/bin:/usr/bin:/bin”
-D AP_UID_MIN=500
-D AP_USERDIR_SUFFIX=”public_html”
It turned out there was no /var/log/httpd directory, so there was nog suexec-log. (No, my setup is not default…) After creating the /var/log/httpd-directory and accessing my test.cgi, the logfile was created, but…
There appared a line in my apache-logfiles:
(13)Permission denied: access to /cgi-bin/test.cgi denied
Luckely a had a suexec-logfile by now, telling me:
user mismatch (daemon instead of nobody)
Meaning: Apache is running as the user daemon, while the default seams to be nobody.
So, at the end I recompiled Apache using:
CFLAGS= -O3 -march=core2 -pipe -O3 -march=core2 -pipe -O3 \
-march=core2 -pipe
OPTS= --prefix=/etc/httpd --sysconfdir=/etc/httpd/conf --exec-prefix=/usr --sbindir=/usr/sbin --libexecdir=/usr/libexec/httpd/modules --datadir=/var/www --sharedstatedir=/var/run/httpd --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include/httpd --infodir=/usr/share/info --mandir=/usr/share/man --enable-so --enable-rewrite --enable-mime-magic --enable-exception-hook --enable-layout=GNU --enable-usertrack --with-apr=/usr --with-apr-util=/usr --with-berkeley-db --with-gdbm --enable-ssl --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-suexec --with-suexec --with-suexec-caller=daemon --with-suexec-docroot=/home --with-suexec-logfile=/var/log/httpd/suexec --with-suexec-bin=/usr/sbin/suexec --with-suexec-uidmin=500 --with-suexec-gidmin=500 --enable-cgid --with-mpm=prefork
Since my suexec-docroot is somewhere else (not /var/www), notice there is a “--with-suexec-docroot=/home”
Hope this helps!