Home > PHP Tutorials > How to configure PHP on Apache Windows

How to configure PHP on Apache Windows

September 29th, 2007

If you have a stable installation of Apache, then installing PHP is very simple. Read the post on How to Install Apache on Windows if you wish to start with installing Apache first.

Lets begin the configuration.

Step 1: Download the Package

Visit http://www.php.net and download the latest stable release version of PHP which is PHP 5.2.4 as of this writing.

You should download the PHP 5.2.4 zip package.

Step 2: Extract the package

Extract the package to a folder on your drive. I work with C:\php5 and am going to use that as the PHP install folder for this tutorial.

Step 3: Copy php.ini file to Windows Folder

Locate the php.ini-dist file in the PHP install folder (C:\php5) and rename it as php.ini.

php.ini file is the PHP Configuration File. I will be writing more about this file in the coming days.

Step 4: Configure the Apache Configuration File

More about Apache Configuration file (httpd.conf) is mentioned in the article How to Install Apache on Windows

Open the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf and add the following entries towards the end of the file:

LoadModule php5_module “c:/php5/php5apache2.dll”
AddType application/x-httpd-php .php

PHPIniDir “C:/php5”

The first line tells Apache where to find the PHP DLL library for execution.

The second line tells Apache which file extension to associate with the PHP Engine.

The third line actually is a directive for the PHP5 library to locate the php.ini file. By default the library tries to locate the php.ini file under C:\Windows and C:\Winnt

Step 5: Restart Apache

For all the changes to take effect you need to restart the Apache Server like this Start > Programs > Apache HTTP Server 2.2.6 > Control Apache Server > Restart

Step 6: Test your configuration

To test your configuration, you will need to create a file named info.php in your htdocs folder. Copy the following code in the info.php file.

<? phpinfo() ?>

If you have followed the steps well, then you should be in a position to see an output as mentioned below:



Congratulations!!! if you get to see the above output.


Subscribe to my newsletters

Categories: PHP Tutorials Tags:
Comments are closed.