As it took me quite a lot of time to do this, I’ll post it here so I can find it later if needed.
I tried it on Squeeze but it should be OK on Wheezy too.
We can’t install both PHP 4 and PHP 5 as Apache module. So what we’re going to do is install PHP 5 as Apache module and PHP 4 as CGI.
First, install apache 2.
Secondly, install MySQL server and phpmyadmin if needed.
|
apt-get install mysql-server |
|
apt-get install phpmyadmin |
Then, don’t forget to install FCGID for Apache
|
apt-get install libapache2-mod-fcgid |
Hardest part now : install PHP 4. You can’t imagine how many hours I waste onto trying to install this old s****. But I clearly had no choice.
There is a nice dude which shares packages of PHP 4 online. The best part is, you can add it as a repo for apt.
Packages are there for 64bits versions : http://www.cecak.cz/debian/squeeze/php4/amd64/
Then, just edit you /etc/apt/sources.lists and add
|
deb http://www.cecak.cz/debian/squeeze/php4/amd64/ ./ |
In a terminal, go for
|
apt-get --allow-unauthenticated update |
Then you’re good to go !
And then all extensions you need :
|
apt-get install php4-curl php4-domxml php4-gd php4-imap php4-ldap php4-mcal php4-mcrypt php4-mhash php4-ming php4-mysql php4-odbc php4-pspell php4-recode php4-snmp |
Now, let’s tell Apache to use PHP 4 on a separate virutal host, so you keep PHP 5 by default and PHP 4 only on a special address.
I just copied the default site config. You can call the new file whatever you want.
|
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/php-four |
My virtual host files will be stored in /var/www/php4. My config file looks like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName localhost.php4 ServerAlias www.localhost.php4 DocumentRoot /var/www/php4 <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/php4> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> <FilesMatch "\.ph(p3?|tml)$"> Options ExecCGI FollowSymLinks SetHandler fcgid-script FCGIWrapper /usr/bin/php-cgi .php </FilesMatch> </VirtualHost> |
The most important part is FilesMatch, which will tell Apache to use PHP CGI (PHP 4 here) to execute php files.
Save the file and enable it using
Then restart Apache so it takes all modifications into account.
Last part, we need to edit /etc/hosts file to add our virtual host address to point it to localhost. Simply add
at the end of the file.
Now you should be good to go !
You can show php version putting this code
into a file and go for it into your browser.