mod_php on pair.com

Got a shared hosting account on pair.com? Want to run a PHP script under Apache’s mod_php module, instead of as CGI? Here’s a tip: don’t put the .php file under the cgi-bin/ directory.

This took me literally hours to figure out. Pair’s documentation is generally pretty good, and they have plenty of information about PHP and CGI, but not much about mod_php. I was able to run a PHP script as CGI, by adding a #!/usr/www/cgi-bin/php5.cgi shebang on the first line, but I didn’t want to do that to every PHP file.

I tried copying /usr/www/cgi-bin/php5.cgi into my local cgi-bin/ directory, as pair suggests when using cgiwrap, but that again just led to CGI instead of mod_php. I tried lots of variations of this in my .htaccess:

Action application/php /cgi-sys/php5.cgi
AddType application/php .php


…but no luck. It was only when I happened to read their WordPress instructions and notice that URLs didn’t start with cgi-bin/ that I finally realized I should move the PHP file outside that directory.

Leave a Reply

Your email address will not be published.