Install PHP

Table of contents


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Download & Unpack

  1. Download the latest zip package of the PHP 5.x.x windows binaries from (the zip package is the best choice to work with Apache).
  2. Create a folder to install PHP and unzip the downloaded file into it.

    In this tutorial C:\php will be used as the installation folder.

  3. Rename C:\php\php.ini-dist file to C:\php\php.ini.

Edit PHP settings

  1. Open php.ini with a text editor and scroll down about halfway through the file and look for doc_root, then change it to point to whatever your Apache DocumentRoot is set to (e.g. doc_root = "C:\public_html").
  2. Scroll down a couple of lines and change extension_dir = "./" to the location of the ext folder of your PHP installation (e.g. extension_dir = "C:\php\ext").
  3. Another thing you might want to change is your session path. Search for session.save_path, uncomment it (remove the ; mark) and change it to an existing folder.
    The default windows temporary folder is a valid option (e.g. session.save_path = "C:/%WinDir%/temp").
  4. If you are going to use your server for testing purposes only, I encourage you to search and replace in your php.ini file the error reporting so it gives you more feedback.
    Update the line error_reporting = E_ALL & ~E_NOTICE to error_reporting = E_ALL | E_NOTICE | E_STRICT.

Editing Apache configuration

Using text editor open C:\<APACHE_INSTALLATION_FOLDER>\conf\httpd.conf (in the start-menu there should also be a Edit the Apache HTTP Server httpd.conf Configuration File shortcut) and add the following lines to the end of file:

Apache 2.0.x

LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

Apache 2.2.x

LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

Make sure to point "C:/php/php5apache2.dll" and "C:/php/php5apache2_2.dll" to your PHP installation folder and to change "C:/php" to point to the folder where your php.ini file is (normally your PHP installation folder).


Start Apache (or restart it if it's already running). If it doesn't start or you get any error, call Apache Test Configuration shortcut to see the cause.

To test your PHP simply create a test.php file in your doc_root folder and put these 3 lines in it:


When loaded in your browser - http://localhost/test.php, you should get a long list of PHP variables, settings, etc.