PHP4 and PHP5 per VirtualHost on the same Apache 2 webserver

I assume you have a working Apache 2 installation with PHP4 modules installed, if not run the following and you will have:


sudo apt-get install apache2 apache2-mod-php4

Note: you can also have PHP5 installed as module and PHP4 as CGI, everything works the same way with swapping the versions in commands.

First of all you will need the php5-cgi package, and enable the Actions module:


sudo apt-get install php5-cgi
a2enmod actions

Add a ScriptAlias directive to your apache2.conf - if you have not done this already - like this:


ScriptAlias /cgi-bin /cgi-bin

Now create the /cgi-bin directory and symlink the php5-cgi binary to /cgi-bin/php5-cgi:


mkdir /cgi-bin
ln -s /usr/bin/php5-cgi /cgi-bin/php5-cgi

Finally in every VirtualHost where you need PHP5 support put these lines:


AddHandler php5-script .php
Action php5-script /cgi-bin/php5-cgi

All you have to do is restart the apache to take changes effect and you’re done.

This entry was written by kakaopor , posted on Friday October 09 2009at 11:10 am , filed under Uncategorized and tagged , , , , , . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

Leave a Reply

i
north-supercharged