Tue 16 Jan 2007
Run 2 Versions of PHP concurrently on Windows
Posted by Marian Dobre under PHP , PHP ArticlesNo Comments
A popular debate is how to run 2 versions of PHP at the same time. This extract shows two ways to achieve this.
Requirements:
- Apache 2x installed
- PHP versions
This assumes that you have followed the steps outlined in the other articles in this section. In this example we will add PHP6 to the existing installation of PHP5.2.x.
The first step is to download PHP6, you can get it here. The binaries come without an installer, so just extract all files to a folder of your choice.
To follow previous articles, I have set the install path as X:\Program Files\Apache Group\php\php-6.0.0-Win32. If you have already created hosts.conf open it using a text editor, wordpad or notepad, and add a few lines. The file, from the default installation is found in the X:\Program Files\Apache Group\Apache2\conf folder. If you haven’t created the file, just open up your httpd.conf.
Without any further changes to these conf files, you can add the following to get PHP6 running simultaneously as a CGI with PHP5 already running as a module.
Thanks to Thierry for this tip.
Listen 81
# Sets Apache to listen to additional port
NameVirtualHost *:81
#
<VirtualHost *:81>
# Allow Apache to run the CGI when on port 81
SetEnv PHPRC "X:/Program Files/Apache Group/php/php-6.0.0-Win32"
ScriptAlias /php6/ "X:/Program Files/Apache Group/php/php-6.0.0-Win32/"
Action php6-script /php6/php-cgi.exe
AddHandler php6-script .php
DirectoryIndex index.php6 index.php index.html index.html.var
</VirtualHost>
That’s it basically. Make changes to your php.ini file as required. Restart Apache, make a test page and see what you get over port 81. You can of course add more here, but the first 4 lines are the important part.
Alternatively, to run PHP as a CGI through the default port, you can add the following instead. Note the AddHandler extenstion.
ScriptAlias /php6/ "X:/Program Files/Apache Group/php/php-6.0.0-Win32/"
Action php6-script /php6/php-cgi.exe
AddHandler php6-script .php6
Please see PHP4 & PHP5 for information how to run 2 versions as Apache modules.
Note: Changes to PHP configurations files will be needed.
There are generic tips here. More specific settings will be posted in this section shortly.
Source: http://www.skiffie.com/code/server/run-2-versions-php-simultaneously.