Installing PHP Files on Windows

Unlike building and installing PHP on Linux/Unix, installing PHP on Windows requires nothing more than downloading the distribution and moving a few files around. To download the PHP distribution files, go to the home of PHP,, and follow the link to the Downloads section. Grab the latest version of the zip package from the Windows Binaries section?for this example we are using 4.2.3. Your distribution will be named something similar to, where version is the most recent release number.

Once the file is downloaded to your system, double-click on it to launch your unzipper. The distribution is packed up with pathnames already in place, so if you extract the files to the root of your drive, it will create a directory called php-version-Win32, and place all the files and subdirectories under that new directory.

Now that you have all the basic PHP distribution files, you just need to move a few of them around:

  1. In the PHP installation directory, find the php.ini-dist file and rename it php.ini.

  2. Move the php.ini file to C:\WINDOWS\ or wherever you usually put your *.ini files.

  3. Move the php4ts.dll file to C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files.

To get a basic version of PHP working with Apache, you'll need to make a few minor modifications to the Apache configuration file.

Integrating PHP with Apache on Windows

To ensure that PHP and Apache get along with one another, you need to add a few items to the httpd.conf configuration file. First, find a section that looks like this:

# Example:
# LoadModule foo_module modules/
LoadModule access_module modules/
LoadModule actions_module modules/
LoadModule alias_module modules/
LoadModule asis_module modules/
LoadModule auth_module modules/
#LoadModule auth_anon_module modules/
#LoadModule auth_dbm_module modules/
#LoadModule auth_digest_module modules/
LoadModule autoindex_module modules/
#LoadModule cern_meta_module modules/
LoadModule cgi_module modules/
#LoadModule dav_module modules/
#LoadModule dav_fs_module modules/
LoadModule dir_module modules/
LoadModule env_module modules/
#LoadModule expires_module modules/
#LoadModule file_cache_module modules/
#LoadModule headers_module modules/

At the end of this section, add the following:

LoadModule php4_module c:/php-version/sapi/php4apache2.dll

Next, look for this section:

# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.

Add the following lines:

AddType application/x-httpd-php .php .phtml .html
AddType application/x-httpd-php-source .phps

This ensures that the PHP engine will parse files that end with the .php, .phtml, and .html extensions. Your selection of filenames may differ, and you may wish to add .php3 as an extension, for backwards compatibility with any very old scripts you may have.

Any files with the .phps extension will be output as PHP source. That is, the source code will be converted to HTML and color-coded. This can be useful for debugging your scripts.

Save this file, and then restart Apache. If the server starts, PHP is now part of the Apache Web server.

    Part III: Getting Involved with the Code