Question

I am trying to get cgi scripts working with a clean build of httpd-2.4.6 on SciLinux 6 - x86_64.

My httpd.conf file: http://pastebin.com/P0CKYfqU

This is essentially the one that was installed - with a few edits.

I do have:

ScriptAlias /cgi-bin/ "/var/tmp/apps/cgi-bin/"

in the httpd.conf file.

I built httpd using the following configure command:

./configure --prefix=/var/tmp/apps --with-apr=/var/tmp/apps/bin/apr-1-config --with-apr-util=/var/tmp/apps/bin/apu-1-config --with-pcre=/var/tmp/apps/bin/pcre-config --enable-cgi

I have done the following to /var/tmp/apps/cgi-bin/printenv

  1. edited the #! line
  2. done chmod a+rx

The command works from the command line.

However, when I go to localhost:8001/cgi-bin/printenv I just see the script itself - not the output of the script.

I'm sure I must be missing a configure option or an httpd.conf directive.

Was it helpful?

Solution

It turrns out that in httpd-2.4.6 the mod_cgi module is not built or enabled by default.

Here is a build recipe which works:

Build httpd with there configure options:

configure \
  --prefix=$TOP \
  --with-apr=$TOP/bin/apr-1-config \
  --with-apr-util=$TOP/bin/apu-1-config \
  --with-pcre=$TOP/bin/pcre-config \
  --enable-modules=all \
  --enable-proxy \
  --enable-proxy-http \
  --disable-userdir \
  --enable-cgi

And then in the httpd.conf file make sure the mod_cgi.so module is loaded:

LoadModule cgi_module modules/mod_cgi.so

To get the printenv cgi script to work, add the ExecCGI option to the options for the /cgi-bin/ directory:

 <Directory "/var/tmp/apps/cgi-bin">
     AllowOverride None
-    Options None
+    Options +ExecCGI
     Require all granted
 </Directory>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top