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 PHP-5.0.0RC2>
  LoadModule PHP5_module C:\PHP\Distributions\PHP-5.0.0RC2\PHP5apache.dll

<ifdefine PHP-5.0.0RC3>
  LoadModule PHP5_module C:\PHP\Distributions\PHP-5.0.0RC3-Win32\PHP5apache.dll

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 checkout phpweb/distributions (extract all)


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 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.

  • Share/Bookmark