Parallel Instances of PHP on Windows
Firstly, PHP has very little dependencies. It does not need any files copied to the system root as many installation instructions state (with the exception of certain PHP extensions).
|
PHP from the command line.
Usage: PHP [options] [-f] <file>[--][args...]
PHP [options] -r <code> [--] [args...]
PHP [options[ [-B <begin_code>] -R <code>[-E <end_code>] [--] [args...]
PHP [options] -B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
PHP [options] -- [args...]
|
|||
| -a | Run interactively | ||
| -c | <path>|<file> | Look for PHP.ini file in this directory | |
| -n | No PHP.ini file will be used | ||
| -d | foo[=bar] | Define INI entry foo with value 'bar' | |
| -e | Generate extended information for debugger/profiler | ||
| -f | <file> | Parse <file>. | |
| -h | This help | ||
| -i | PHP information | ||
| -l | Syntax check only ( lint) | ||
| -m | Show compiled in modules | ||
| -r | <code> | Run PHP <code> without using script tags <?..?> | |
| -B | <begin_code> | Run PHP <begin_code> before processing input lines | |
| -R | <code> | Run PHP <code> for every input line | |
| -F | <file> | Parse and execute <file> for every input line | |
| -E | <end_code> | Run PHP <end_code> after processing all input lines | |
| -H | Hide any passed arguments from external tools. | ||
| -s | Display colour syntax highlighted source. | ||
| -v | Version number | ||
| -w | Display source with stripped comments and whitespace. | ||
| -z | Load Zend extension <file>. | ||
| args… | Arguments passed to script. Use — args when first argument starts with - or script is read from stdin | ||
As we can see a number of options can be passed to PHP that manipulates the way PHP acts. This will allow us to define the location of PHP.ini, if defined at all or other parameters that maybe injected. Apache is also configurable in a manner that will allow us to choose the PHP version to run upon apache's execution. For Example placing the following in httpd.conf will allow you to choose the version of PHP to be executed with apache.
<ifdefine PHP-5.0.0RC1>
LoadModule PHP5_module C:\PHP\Distributions\PHP-5.0.0RC1-Win32\PHP5apache.dll
</ifdefine>
<ifdefine PHP-5.0.0RC2>
LoadModule PHP5_module C:\PHP\Distributions\PHP-5.0.0RC2\PHP5apache.dll
</ifdefine>
<ifdefine PHP-5.0.0RC3>
LoadModule PHP5_module C:\PHP\Distributions\PHP-5.0.0RC3-Win32\PHP5apache.dll
</ifdefine>
Using ' apache.exe -D PHP-5.0.0RC3-Win32'.
Note: IfDefine is case sensative, also ensure Capital D is used in the command line as lower case has a different function (-d directory initial value for ServerRoot & -D parameter define parameter for <ifdefine>).
If any failures occur at this point, there are two common reasons, firstly in early versions of PHP, version 4 requires PHP.ini & PHP4ts.dll. As so many installation manuals like to tell you DO NOT PLACE ANY FILES IN THE SYSTEM ROOT, the best way to encapsulate installations is by placing any required file in the root path of the PHP.exe location, if using CLI copy the (PHP4ts.dll or PHP5ts.dll) & PHP.ini to that directory.
The order for PHP is to locate required files is %system%, %system32%, %systemroot%, %apacheroot%, %phproot%; in the general order of the system variable %path%. I recommend the follow directory structure when installing PHP…
cvs -d :pserver:cvsread@cvs.PHP.net:/repository checkout phpweb/distributions (extract all)
C:.
---PHP
+---Distributions
+---PHP-3.0.17-win32
+---PHP-4.3.2-Win32
+---PHP-4.3.3-Win32
+---PHP-4.3.4-Win32
+---PHP-4.3.5-Win32
+---PHP-4.3.6-Win32
+---PHP-4.3.7-Win32
+---PHP-5.0.0RC1-Win32
+---PHP-5.0.0RC2-Win32
+---PHP-5.0.0RC3-Win32
For each, rename 'PHP.ini-dist' to 'PHP.ini' and if applicable copy 'PHP.ini-dist' & 'PHP4ts.dll/PHP5ts.dll' to the directory 'cli' as well as ammending 'PHP.ini' temp path to your systems temp. From each %rootphp% path you can configure that installation with its own customised 'ini'. I recommend reading PHP directives at php.net. From this you can setup VirtualHosts, such as http://PHP4/, http://php5/ etc, which will make switching between PHP 3, 4 & 5 simple :). Note: This is for development purposes and should not be used in a production enviroment.
on March 14th, 2005 at 4:17 pm
Hi,
Tried to find another solution but didn’t find yet…still searching 
i’m trying to reproduce your install. Have installed apache 1.3.31 and PHP 5.0.0 for the moment. I have put a php.ini file in my PHP5 directory. When I launch the service, everything seams to work fine but if I look a phpinfo(), i can see that the php.ini file is not loaded, all values are default. I’ve tried putting the php.ini in the apache directory or in the windows directory and both work. So it seams putting the php.ini files in the PHP directory is not possible anymore, and so this type of install can’t be done
Romain
on March 14th, 2005 at 4:17 pm
Hi,
to have PHP 5.0.0 and PHP 4.3.8 on the same Windows server, use WAMP5 :
http://www.en.wampserver.com
It comes with PHP 5.0.0 and an add-on installs PHP 4.3.8 and lets you switch from one to another…
on March 14th, 2005 at 4:18 pm
Pointer:
Switching PHP
Also defining the location of the php.ini file can now be set via…
# configure the path to php.ini
PHPIniDir “C:/php”
or
# specify the directory where php.ini is
SetEnv PHPRC C:/php
on December 20th, 2005 at 5:44 pm
[...] For more on configuring windows see the following… Parallel Instances of PHP on Windows Apache & IIS Multiple Address on Port 80 [...]