Running PHP4 and PHP5 in Parallel, The Easy Way

PHP4 and PHP5

Running PHP4 and PHP5 on the same server really isn’t that difficult, here is how I have it all setup. My system installation basically looks like the following:

Windows
Apache2
MySQL
PHP5 (installed as module via PHP windows installer)
PHPx (different PHP versions running as CGI)

I divide my different projects across multiple virtual hosts as such:

# httpd-vhosts.conf
 
NameVirtualHost 192.168.1.150:80
 
<VirtualHost 192.168.1.150>
 
    ServerAlias myhost
    DocumentRoot C:/Apache2/docs/farinspace/trunk/myhost/web/html
 
</VirtualHost>
 
<VirtualHost 192.168.1.150>
 
    ServerAlias myhost2
    DocumentRoot C:/Apache2/docs/farinspace/trunk/myhost2/web/html
 
</VirtualHost>
 
<VirtualHost 192.168.1.150>
 
    ServerAlias myhost3
    DocumentRoot C:/Apache2/docs/farinspace/trunk/myhost3/web/html
 
</VirtualHost>

As you may or may not have noticed, I am using custom host names for my projects, I do this with the windows HOST file.

The default version across all my virtual hosts is PHP5. However, for certain projects I need to develop and test with specific PHP versions. To set this up, I must run the different version of PHP in CGI mode (Apache will only run a single PHP version as a module, in my case, PHP5 is running as an Apache module).

I download the PHP release I need (the zip file) and unzip it to the root at C:/php447. The “C:/php447/php.ini-recommended” file needs to be renamed to “php.ini” and configured.

I then set the virtual host as follows (If you don’t use virtual hosts, you will still need to use the the pertinent parts of the Apache config statements to setup your server):

# httpd-vhosts.conf
 
<VirtualHost 192.168.1.150>
 
    ServerAlias myhost3
    DocumentRoot C:/Apache2/docs/farinspace/trunk/myhost3/web/html
 
    ###
 
    SetEnv PHPRC "C:/php447/"
    ScriptAlias /php447/ "C:/php447/"
    Action application/x-httpd-php447 "/php447/php.exe"
    AddType application/x-httpd-php447 .php .inc
 
    # IMPORTANT: apache 2.2 denies access to the php 
    # cgi executable, unless it is explicitly granted
 
    <Directory "C:/php447/">
        <Files "php.exe">
            Allow from all
        </Files>
    </Directory>
 
    ###
 
</VirtualHost>

Remember to restart Apache after you’ve modified your “httpd-vhosts.conf” file and do a quick test with a “phpinfo.php” file:

<?php phpinfo(); ?>

Tip: because the version of PHP4 is running as a CGI, you will NOT need to restart Apache every time you modify the php.ini file.

If you have a different setup, please do share …

Related posts

  1. Apache and PHP Error… Faulting module name: php5ts.dll

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
<pre lang="" line="" escaped="">

Previous post:

Next post: