#native_company# #native_desc#
#native_cta#

Running PHP from cgi-bin

By Arthur Watts
on September 20, 2001

If you are running the <i>mod_php</i> version of PHP and you want to store your PHP source alongside the other server-side scripting languages in Apache’s ‘cgi-bin’ directory (or the location for your own script repository), you need to realise that it is usually setup with the Apache ‘ScriptAlias’ directive : PHP needs to be forwarded to the httpd process and most scripts do not. IF you have access to your web server config, edit your httpd.conf to read something like this :

Alias       /cgi-bin "/intranet/admin/cgi-bin"

<Directory "/intranet/admin/cgi-bin">
AllowOverride All
Options       FollowSymLinks ExecCGI
Order         allow,deny
Allow from all
</Directory>

The above is from the config for one our virtual servers, but the principles are the same : change ‘ScriptAlias’ to ‘Alias’ for cgi-bin, then instruct Apache to <i>ExecCGI</i> in that directory. To ensure that Apache knows about non-Perl CGI, add these to the top of the file:

 AddHandler cgi-script .cgi
 AddHandler cgi-script .py

Good Luck.