If you have a shared hosting company and are still running PHP4, you might feel the pressure rising. Articles like ‘Now showing: PHP’s true colors’ basically tell you to make the switch and take the hit, but they do not give any advice how to handle this.

The basic problem is that you can inform your customers that you’re migrating to PHP5, but if you can’t provide a testing platform for your customers, how are they going to know if migrating will break their sites.

A few months ago I’ve posted an article about running multiple Apache instances with different PHP versions. In that article I showed how to make multiple configurations running Apache on different IP addresses. By using different ports instead of different IP addresses, we can give our customers a way to check their site before it goes live.

If you haven’t read the article, start with that. On step 2 ‘Create additional apache configuration files’ you need need to do it slightly different though. Follow the whole article, but in step 2 do (not using mod_macro):

Remove PHP4 from mods_enabled and the Listen directive from the ‘apache.conf’ file.
Create apache2-php4.conf:

Include /etc/apache2/apache2.conf
Listen 192.168.1.50:80

LoadModule php4_module /usr/lib/apache2/modules/libphp4.so
<IfModule mod_php4.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

Create apache2-php5.conf:

Include /etc/apache2/apache2.conf

LockFile /var/lock/apache2/apache2-php5.accept.lock
PidFile /var/run/apache2-php5.pid
ErrorLog /var/log/apache2/error-php5.log
Listen 192.168.1.50:8800

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

In this example replace ‘192.168.1.50′ with your own IP address. Restart Apache and it will start up 2 instances, one with PHP4 running on port 80 and one with PHP5 running on port 8800. Now you can send out a mailing to all your customers, reporting that you change to PHP5 in a number of weeks and that they should check if their website would experience problems by going to http://www.example.com:8800, where example.com should be replaced by their domain name.

This setup is not tested, so please tell me if it is not working.