Part 3 – Install PHP 5

Articles in the Series
Part 1 – Download Apache, PHP and MySQL
Part 2 – Install Apache HTTP web server
Part 3 – Install PHP (this article)
Part 4 – Install MySQL

Unzip the PHP zip package that downloaded in Part 1 to C:\PHP (Create a new folder named PHP at C:\ root level). Then shut down Apache server.

Open the Apache httpd.conf with a text editor and add two lines of code:

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

Added .php extension to show how to parse .php files

Note that use of forward slashes instead of backslashes in the configuration file.

Note also the directory in load module points to where we installed PHP. So if you install PHP at other location, change it accordingly. The directory style should be / too instead of common DOS syntax.

These two lines can be added to the bottom of the httpd.conf file. However, note that modules in the load list are in reverse-priority order; those that come later can override or pre-empt those listed earlier. Therefore, adding php_mod at the end of the list can have unexpected results, such as disabling mod_rewrite (and other modules) for any php files that exist (mod_rewrite will run fine if the file doesn’t exist). The same error can disable mod_auth and other important modules. In summary, php_mod should be loaded before any modules you wish to run before your php code is executed. See the note in the Apache AddModule documentation for how to find the recommended ordering.

Next, copy/paste “php.ini-recommended” to C:\Program Files\Apache Group\Apache2 (or your Apache installation path), and rename it to php.ini. Restart the Apache server.

Testing php5 Installation

Create a file with the following contents and save it to the root web folder (C:\Server\htdocs or default C:\Program Files\Apache Group\Apache2\htdocs\) as “php5info.php”.


Access the following url http://localhost/php5_info.php. The complete PHP setting should be displayed on the browser. If there is an error or nothing been shown, there is problem with installation. Try the installation procedures again.

Enable MySQL extension

The php.ini that copied from php.ini-recommended already being set to optimum setting, so there is no special need to edit it. However, it still need to edit to enable mysql extension.

Open php.ini in the Apache2 directory with text editor.

Search for the line of extension_dir = “./”. Change it to extension_dir = “C:/php5ext”. Also, uncomment the line of extension=php_mysql.dll.

Save the php.ini. Restart the Apache server. Re-try to access http://localhost/php5_info.php. It should working fine. If not try to check what’s the cause of errors, which most likely due to wrong extension_dir or missing extension. Or you may try to copy all the needed extentions (with .dll extenstion) to Apache2 directory.