I have a unique requirement where I want to run PHP 4 and PHP 5 on the same web server. How do I acheive it ?
views:
27answers:
4You will have to write a lot of conditional code with version checking and take the appropriate step if it is one or the other version something done by the CodeIgniter PHP framework.
But first, you will have to know the differences between php4 and php5.
You might want to do a startup with a checking version of php:
if (version_compare(phpversion(), '4', '>='))
{
// code.......
}
I've seen shared hosters that use different file extensions to distingush if php 4 or 5 should be used. So they register .php5 for PHP5 and .php for PHP4 in Apache. It is not exactly elegant, but one possibility.
I believe you can run one as an Apache module, the other as cgi.
You can run two different versions of PHP with suPHP This documentation is a little outdated - but the approach is the same http://www.howtoforge.com/apache2_suphp_php4_php5 (for instance there are update suPHP builds, and depending on what flavor you deploy on will dictate the sources of your packages)
I love suPHP and use it frequently in most my server builds since it dissolves a lot of user/group issues you find in typical setups.