Using an .htaccess with PHP Compiled as CGI

Posted by Nessa | Posted in ,,, | Posted on December 6, 2007

3

We recently started installing suPHP on a few of our servers, which is an implementation of phpsuexec, only a ton faster and with less overhead. Yesterday I posted a tutorial on how to install suPHP on a PHP5/Apache server outside of EasyApache, but today I shall go over how to enable PHP directives in your .htaccess instead of using the php.ini.

First of all, if you’d rather use the .htaccess than the php.ini capabilities of a phpsuexec environment, then shame on you. But, we have some customers who are terrified of php.ini and would rather use the .htaccess. So what? Ok, well there is a workaround. Mr. Joye released a newer version of htscanner that now works with suPHP, and allows you to use php directives in your .htaccess just like you did when PHP was installed as and Apache module. All you have to do is download the tarball and install like any other PHP module:

wget http://pecl.php.net/get/htscanner-0.8.1.tgz

tar -xvzf htscanner-0.8.1.tgz

cd .htscanner-0.8.1

./configure && make && make install

Then add a loader for the resulting binary to your php.ini:

extension=”/htscanner.so”

From here, you can add your php_value and php_flag statements to your .htaccess as usual within <ifmodule> tags. I should note that the reason why you normally would not be able to overwrite php.ini values in your .htaccess is because .htaccess is an Apache file. Under phpsuexec/suPHP, PHP runs as a CGI module so Apache does not understand what those mean, so it will either ignore them all together or return a nasty 500 error.

Be Sociable, Share!

Comments (3)

Nessa’s Blog: Using an .htaccess with PHP Compiled as CGI…

Nessa has posted another new tutorial based around her experiences with ……

[…] has posted another new tutorial based around her experiences with suPHP. This time it deals with using an .htaccess file for […]

I want to add this as a bug:

It seems that with htscanner you cannot add multiple paths, as it only sees the first and/or second one. You can read and contribute to the bug report here:

http://pecl.php.net/bugs/bug.php?id=12696

Post a comment