September 9, 2007 (17 years ago)

PHP 5.2.5 on Windows XP with Apache Server 2.0.46 Quick Manual Installation Guide

Configure PHP 5.2.5 to run with Apache Server 2.0.46 as a web server module.

Despite the availability of an installation manual, most people would opt to do the much-dreaded complicated installation of PHP as packed in those all-in-one installers found over the internet. None of those are endorsed by, makers of PHP, as they believe that the manual installation is still the best choice to have your system secure and optimised. What makes the installation so complicated is PHP's flexibility, the availability of path choices presented in the manual together with the text-based configuration involved to load the PHP module properly. What we have here is a single installation path for you to follow to get PHP 5.2.5 to run on Windows XP coupled with the Apache 2.0.46 web server.

Install PHP

  1. Download the PHP 5.2.5 zip package under Windows Binaries from The advantage here is the smaller download size, compared to the installer package which is about twice bigger.
  2. Extract the zip package contents to C:\php or whichever drive your Windows is installed in. D:\php if Windows is installed in drive D.
  3. Go to your php directory and duplicate file php.ini-recommended. Rename the copy to php.ini.
  4. Open php.ini with Notepad or Wordpad. Find (Ctrl+F) “extension_dir” and change the value as shown:
    extension_dir = "C:\php\ext"
    This directs PHP to load extensions, including MySQL and GD support, disabled by default in this version of PHP, from the C:\php\ext directory. If you wish to enable an extension, uncomment the corresponding extension=php_*.dll line for that extension by deleting the leading ; from the extension you want to load. Find (Ctrl+F) “Windows Extensions” and find below an extension dll you wish to enable. The following enables MySQL and GD support required by some PHP applications such as phpBB3:
  5. We have to make sure that php5ts.dll in the PHP installation directory can be found during server startup. Let's add its location to the Windows PATH environment variable. Press Windows+Pause Break keys to invoke System Properties. Go to the Advanced Tab and click on Environment Variables. Double-click Path under System Variables and append your PHP directory at the end, including ; before it as shown in the example:
  6. Click OK and restart your computer.

Configure Apache Server

We're basically done with PHP installation. Let's now configure Apache to load PHP as a module.

  1. Open your Apache configuration file with Notepad or Wordpad. The easiest way to access it is through the Apache program group: Start > All Programs > Apache HTTP Server 2.0.46 > Configure Apache Server > Edit the Apache httpd.conf Configuration File.
  2. Find (Ctrl+F) “LoadModule”. In the LoadModule section, insert the following line:
    LoadModule php5_module "C:/php/php5apache2.dll"
    This loads PHP as an Apache module during web server startup.
  3. Find (Ctrl+F) “AddType”. In the AddType section, insert the following line:
    AddType application/x-httpd-php .php
    # For syntax highlighted .phps files
    AddType application/x-httpd-php-source .phps
    This will execute .php and .phps files in your web server directory as php applications.
  4. Add the following as well:
    # configure the path to php.ini
    PHPIniDir "C:/php"
    This will load the php.ini configuration file that we have earlier created. Make sure you have set the correct path drive.
  5. Find (Ctrl+F) “DirectoryIndex”. In the DirectoryIndex directive, add index.php to the list of default files as shown in this example:
    DirectoryIndex index.php index.html index.htm index.html.var default.htm default.html
    Index.php files will be loaded if only the directory is specified in the browser url such as a website's beginning page.
  6. Save the configuration file.
  7. Restart Apache server. The recommended way is through the Apache program group: Start > All Programs > Apache HTTP Server 2.0.46 > Control Apache Server > Monitor Apache Servers. R-click the Apache icon in the system tray > Open Apache Monitor. Click Restart button. If the log says:
    The Apache2 service has restarted.
    Your Apache configuration file was set correctly. Otherwise, check your configuration file for typo errors specially lines with quotation marks. Make sure to replace them with the keyboard quotation mark key.

PHP Test

Let's now test if PHP is running correctly.

  1. Create an html file named phpinfo.html in your web server directory and insert this code within the ‹body› tags:
  2. Access phpinfo.html in your browser. A status information table for PHP should display the following:
    Loaded Configuration File
    This shows that our PHP configuration file is loaded. mysql and gd settings should also display farther down if they are enabled.