Using the Windows Installer for PHP 5.2.x

PHP 5.2.0 saw the launch of a vastly improved installer for Windows. Unlike earlier versions, the new installer automates the installation of a fully featured version of PHP on a wide variety of web servers, including the Apache 1.3, 2.0, and 2.2 series, as well as IIS.

These instructions assume that you have already installed a web server on your local computer. They have been tested on Apache 2.2 and IIS 5.1, but they should be easily adaptable to other web servers. Before testing these instructions, I removed my existing PHP setup completely, including all Windows environment variables, such as PHPRC and the the reference to the PHP folder in the Windows PATH. They are therefore suitable for a brand new installation of PHP, but may not work if you have an existing installation that you want to upgrade.

The new Windows package will not work on Windows 98 unless you have obtained an MSI installer from Microsoft.

In Windows Vista, you must disable User Access Control (UAC) temporarily while installing both Apache and PHP—see instructions here.

  1. Go to the PHP downloads page at and select the PHP 5.2.x Installer from the Window Binaries section. Note that the download is nearly 19MB (twice the size of the equivalent zip package). Download php-5.2.x-win32-installer.msi from a mirror site and save the file to your hard disk.

  2. Close all Windows programs and double-click the php-5.2.x-win32-installer.msi file to launch the installation wizard. You should eventually be greeted by the following screen. Click Next to start the installation.

    PHP Installation Wizard welcome screen

  3. The first dialog box displays the PHP Licence Agreement. You need to select the accept checkbox before the Next button can be clicked.

  4. The wizard now gives you the option to choose where PHP should be installed. The default is C:\Program Files\PHP\. Unless you have a strong reason for choosing another location, accept the default and click Next.

  5. You now get the chance to select the web server that you want to use in conjunction with PHP. As you can see from the screenshot, there's a wide selection. I chose to install PHP as an Apache 2.2.x Module.

    Selecting a web server

    If you are using IIS, select IIS CGI. (The screenshot above was taken from the PHP 5.2.0 installer. In PHP 5.2.1, the IIS options have been renamed.) Although running PHP as an ISAPI module is preferable, the IIS ISAPI module option isn't currently enabled in the installer. Make your selection and click Next.

  6. If you chose IIS in the preceding step, skip to step 7.

    If you chose Apache, the wizard asks you to specify where the configuration file is located. In the case of Apache 2.2.x, it's C:\Program Files\Apache Software Foundation\Apache2.2\conf\, as shown in the following screenshot.

    Selecting the location of the Apache configuration file

    Browse to the appropriate folder, click OK to return to the installation wizard, and then click Next.

  7. The next dialog box lets you select which PHP extensions will be enabled. PHP offers a huge range of non-core extensions, so it's best to choose only those that you know you'll need. Click inside the dialog box to expand the Extensions tree menu. As an absolute minimum, you should select GD2, Multi-Byte String, MySQL, and MySQLi. Click the down arrow next to the extension name and select "Will be installed on local hard drive", as shown in the screenshot. The red X is replaced by a hard drive icon, indicating that the extension will be enabled.

    Selecting PHP extensions

    If you are using The Essential Guide to Dreamweaver CS3 or Foundation PHP for Dreamweaver 8, you should also select XSL. For PHP Solutions, expand PDO and select MySQL (this is in addition to MySQL and MySQLi in the main extension list).

    If you plan to do a lot of PHP development, you might also want to enable the Extras, which install PEAR and the PHP documentation on your local hard disk. If in doubt, don't bother. You need to have a solid understanding of PHP to use PEAR, and the online documentation is frequently updated, so having a local version is only of value if you need to work offline a lot.

    Click Next when you have made your choices.

  8. The wizard is now ready to install PHP. If you selected Apache, it asks whether you want it to configure Apache. Click Yes. After the installation, you should see two alert boxes telling you that the Apache configuration and mime.types files were successfully updated. Click OK and then click Finish to close the wizard. If you selected IIS, there are no other dialog boxes. Just click Finish when the installation is complete.

  9. For all the changes to take effect, you must now reboot your computer. Among other things, this is necessary to add the PHP folder to your Windows PATH.

  10. If you run <?php phpinfo(); ?>, you should see that php.ini has been placed in C:\Program Files\PHP\php.ini. (In PHP 5.2.3 and above, the location of php.ini is displayed as Loaded Configuration File.)

Important differences in php.ini

The new Windows installer bases php.ini on php.ini-recommended, which imposes stricter standards than php.ini-dist, the version normally recommended for a development environment. This is generally to be welcomed, because it forces you to create scripts that are more secure. However, you need to be aware of the following differences:

Enabling sessions and uploads

The Windows installer designates C:\Documents and Settings\<username>\Local Settings\Temp\php\upload as the value for upload_tmp_dir and C:\Documents and Settings\<username>\Local Settings\Temp\php\session as session.save_path. However, the installer doesn't create the necessary folders. Consequently, file uploads and sessions won't work until the folders are created. (In Windows Vista, the folders are C:\Users\<username>\AppData\Local\Temp\PHP\upload and C:\Users\<username>\AppData\Local\Temp\PHP\sessions.)

Either open php.ini and rename the current folders to C:\WINDOWS\Temp, or create the necessary folders in C:\Documents and Settings\<username>\Local Settings\Temp (or the Vista equivalent). If you choose the option of renaming the folders, make sure you change the right settings in php.ini. The installer leaves the original commands unchanged and inserts new ones. The original commands have a semicolon at the beginning of the line, so are ignored.

Remember to restart your web server after making any changes to php.ini.

What the PHP installation wizard doesn't do

Although the new Windows installer considerably simplifies setting up PHP on Windows, it doesn't change the default location of DocumentRoot on Apache, nor does it add index.php to the DirectoryIndex command. You still need to make those changes manually to httpd.conf. For instructions on how to do this, see the following:

Other Tutorials

Programming tutorials

Articles on

Over the years, I have contributed a large number of articles to the Adobe Developer Connection and Community publishing. Most of the articles are now in the Adobe archive because they refer to old versions of Dreamweaver. But the following articles are not Dreamweaver-specific and are still relevant.

Books & Videos by David Powers

PHP SolutionsBeginning CSS3Dreamweaver CS6: Learn by VideoDreamweaver CS5.5: Learn by VideoDreamweaver CS5.5 for MobileDreamweaver CS5 with PHP