PHP 5.3 and 5.4 with Directadmin
About 6 months ago PHP 5.4 was released. Given that I love new stuff I did not hesitate installing it on my live server. I soon found out that there had been to many changes and some of my sites were not prepared for this.
Now, 6 months later, I decided I had to do something in order to be up to date. I decided to go for a dual install of PHP. This is how I did.
In Directadmins forum i found a guide to install 5.2 and 5.3 but it didn't work for me with 5.3 and 5.4.
This guide will allow you to have both versions installed, but with 5.3 as default.
./build set custombuild 1.2
mkdir -p custom/suphp
cp -pf configure/suphp/configure.php5 custom/suphp/configure.php6
perl -pi -e 's/\/usr\/local\/php5/\/usr\/local\/php6/' custom/suphp/configure.php6
perl -pi -e 's/php54/phprep/' versions.txt
perl -pi -e 's/php6/php54/' versions.txt
perl -pi -e 's/phprep/php6/' versions.txt
./build set php5_ver 5.3
./build set php6_cgi yes
./build set php5_cgi no
./build set php5_cli yes
./build php n
# Verify that /usr/local/php6 exists. If not, figure out why before going further.
mv -f /usr/local/php6 /usr/local/php6_old
ln -s /usr/local/php5 /usr/local/php6
At this point everything should work as before you started. All websites on the server running PHP 5.3. Please check your websites to ensure they work. If not, roll back.
Before we start to use PHP 5.4 there are some setting in suphp that you need to consider. Per default suphp will not execute .php files, where group has write access. Upside of this is the security. Downside is that it only take a single file to corrupt a system.
If you wish to turn it off, you should go the config file and change it.
Set these to true to have the more "flexible" approach.
We are now ready to test it out. Go to a website that can display your PHP version, or just pick a random and make a file with phpinfo(). Make a .htaccess file and insert the following:
AddHandler x-httpd-php6 .php
I'm aware that it says PHP 6 here, but this is just because there are only one PHP5 tag, and currently I'm not using PHP6 tags. This will enable the current website to use PHP 5.4.
Go go test.