For a long time I wanted to be able to run both PHP 4 and PHP 5 on the same server. Now I finally managed to come up with a solution that is easy to install and easy to use.
- Add the Debian Backports repository to your /etc/apt/sources.list
deb http://www.backports.org/debian/ sarge-backports main contrib non-free
- Issue a package update: aptitude update
- Install PHP 5 as CGI module: aptitude install php5-cgi
- Configure Apache by adding the following lines to your main config file. In my case this was /etc/apache2/apache2.conf
ScriptAlias /php5-cgi /usr/lib/cgi-bin/php5 Action php5-cgi /php5-cgi
- Now find the Virtual Host you want to run on PHP 5 and simply put the following line into the <Directory> directive.
AddHandler php5-cgi .php
This overrides the default handler for files ending in .php which would be the normal PHP 4 module. Whit this directive it is now parsed and executed by the PHP 5 CGI binary. - Reload your webserver config with
/etc/init.d/apache2 reload
There are a few places round the Internet which attempt to explain this, but yours was the only one which worked for me, after several hours hair pulling. Thanks for a great article!
Thank you, thank you. It’s been 3 days of researching and breaking my server. You saved me tons of more heartaches 😀
Hi,
mod_actions was not enabled in the default apache2 install (debian sid) I had. So if a restart looks like this:
$ sudo /etc/init.d/apache2 restart
Restarting web server: apache2Syntax error on line 20 of /etc/apache2/sites-enabled/000-default:
Invalid command ‘Action’, perhaps misspelled or defined by a module not included in the server configuration
failed!
You need to run the following command:
$ sudo a2enmod actions
Thank you so so much. it is really helpful and simple.. after spent too many hours with a lot of combination, you mention the correct one with simple way..
thanks again…
Thank you! You my savior
Thank you!!! For the first restart got same error from @Andrew!
just did “S# sudo a2enmod actions” and all things worked!!!!
I f*cked up my apt-get, trying to do a dist-upgrade from squeeze and php5 was removed, and no way to reinstall php5 as a apache module (ummet depedencies)!!! php5-cgi saved my life!!