PHP on Windows XP/IIS

Posted 25 January 2007, 10:30 | by | | Perma-link

Ok, for some reason this was a lot harder than it should have been, mainly (i guess) because of some ambiguity around installers and the like.

It is the way the PHP documentation states:

Windows Installer (PHP 5.2 and later)

The Windows PHP installer for later versions of PHP is built using MSI technology using the Wix Toolkit (http://wix.sourceforge.net/). It will install and configure PHP and all the built-in and PECL extensions, as well as configure many of the popular web servers such as IIS, Apache, and Xitami.

First, install your selected HTTP (web) server on your system, and make sure that it works. Then proceed with one of the following install types.

Normal Install

Run the MSI installer and follow the instructions provided by the installation wizard. You will be prompted to select the Web Server you wish to configure first, along with any configuration details needed.

This is a lie.

The key to this lie is almost every other page, which directs you to the Manual Installation Steps:

Manual Installation Steps

This install guide will help you manually install and configure PHP with a web server on Microsoft Windows. To get started you'll need to download the zip binary distribution from the downloads page at /downloads.php.

Although there are many all-in-one installation kits, and we also distribute a PHP installer for Microsoft Windows, we recommend you take the time to setup PHP yourself as this will provide you with a better understanding of the system, and enables you to install PHP extensions easily when needed.

Which should be followed.

Basically, the installer will, without asking, install everything by default in C:\Program Files\PHP\. Fine, you think, as it should be. However, it then fails to configure anything in IIS (as I requested in the installer), sets up an environment key %PHPRC% to C:\Program Files\PHP\ - no quotes though, so nothing can use it, and adds the following as entries in the php.ini file:

upload_tmp_dir="C:\DOCUME~1\BENJAM~1\LOCALS~1\Temp\php\session"
session.save_path="C:\DOCUME~1\BENJAM~1\LOCALS~1\Temp\php\upload"

Ignoring the fact that these look to be the wrong way round (Upload to session, sessions saved in Upload?), when I finally got a PHP file to load, I received errors stating that these two lines were badly formed.

This leads me on to the final point:

Initially I was getting a message in the browser:

The specified module could not be found.

That was it, nothing else.

So I gave up, and moved everything to C:\PHP\, changed the Path environment variable, changed the PHPRC variable, repointed the PHP ISAPI handler, and updated the relevant lines in php.ini  - creating a folder structure of Temp\Uploads and Temp\Session under the PHP folder.

Restarted IIS, and Robert's your Mother's Brother, as they say, PHP pages loading in the browser, and executing script.

Filed under: Fixes