Installing PHP on Windows

Installing PHP on Windows requires nothing more than downloading the distribution file. 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 (not the installer!) from the Windows Binaries sectionfor this example, we are using 5.1.4. Your distribution will be named something similar to, where VERSION is the most recent release number.

After the file is downloaded to your system, double-click it to launch your unzipping software. The distribution is packed up with relative pathnames already in place, so extract the files to a new directory called C:\php\, where it will place all the files and subdirectories under that new directory.

Unlike previous versions of PHP, there is no need to move files into various system directories. Only two basic steps need to be performed:

  1. Add your PHP directory to your Windows PATH. If you do not know how to do this, see the corresponding FAQ in the PHP Manual at

  2. In the PHP installation directory, copy the php.ini-recommended file to php.ini. 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 ssl_module modules/

At the end of this section, add the following:

LoadModule php5_module C:/php/php5apache2.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 line:

AddType application/x-httpd-php .php  .html

This statement ensures that the PHP engine will parse files that end with the .php and .html extensions. Your selection of filenames might differ.

Additionally, add the following to ensure Apache knows where php.ini resides:

PHPIniDir "C:/php/"

Save the httpd.conf file and then restart Apache. The server should start without warning; PHP is now part of the Apache web server.

By the Way

If you have trouble getting Apache to read the correct php.ini file, look at the "Runtime Configuration" entry in the PHP Manual, which provides the list of locations searched for php.ini, at

Sams Teach Yourself PHP, MySQL And Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (3rd Edition)
ISBN: 0672328739
EAN: 2147483647
Year: 2004
Pages: 327

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: