How To Configure PHP 5 With Apache 2 On Windows in 2 Minutes

By Angsuman Chakraborty, Gaea News Network
Monday, September 25, 2006

I am assuming that you have downloaded and installed Apache 2.x on your windows machine. Use the latest version 2.2, if you do not have plans to run Subversion on it. Otherwise choose Apache 2.0.x. Install it with the defaults. You may want to however changes the drive on which it is installed. Anyway so you have it running. Then you went to php.net and have downloaded and extracted the zip file to say c:\ or d:\. I am assuming you have then changed the name of php.ini-recommended to php.ini. So far all the steps are straight forward and their install guide is good enough. Now you are feeling happy about it and want to integrate PHP with Apache, right? That’s when the fun begins.

To cut the long story short the instructions in PHP document doesn’t work and have obviously not been updated in a long while. So I will give you a 2 minute guide to glory.

Open httpd.conf (in Drive:\Program Files\Apache Group\Apache2\conf) and search for LoadModule statements. At the end add:
LoadModule php5_module "D:/php/php5apache2.dll"

Then search for directives. At the end add:


	AddType application/x-httpd-php .php
	AddType application/x-httpd-php-source .phps

Note: The last AddType is a nicety. It allows you to view .phps files (php files with extension renamed) in htmlized and colorful format from your browser.

Now restart the server.
Did I say you are done? Well, you are. So go out and enjoy.

Note: If you are a wimp and you don’t need Subversion you may take the easy way out and install Xampp instead. It will do the dirty work for you.

Discussion
May 31, 2010: 2:22 pm

Got over here in search of php config for apache proc… Followed the steps above and made my day..
Thanx….


Lars
May 27, 2010: 11:24 am

One thing to note:

When downloading php, pick the one compiled with VC6 (which is stated) and the zip file, NOT THE WINDOWS INSTALLER. The windows installer DOES NOT CONTAIN the php5apache2.dll, but THE ZIP FILE DOES.


Stuart
December 9, 2009: 5:36 am

Thanks so much for this, the instructions on php.net are pretty terrible and this solved my problem.

However, in the version of php5 I have, there is no php5apache2.dll, it is called php5apache2_2.dll, just thought I’d mention it.


zedu
November 11, 2009: 1:26 pm

thanks,its awesome it worked for me on windows xp,but the smae works on windows server 2003…please replyy mee…its very urgent

September 30, 2009: 5:08 pm

Thanks. It really helped me to set up php and Apache on Windows XP.


Ben
September 10, 2009: 6:03 am

Thanks, worked a treat! As mentioned below, make sure you use php5apache2_2.dll if using php5.3 and apache 2.2 though.


umer ahmad
September 1, 2009: 1:48 pm

hello..i am having problem integrating PHP 5 with my Apache server 2.2..i have followed the above stated step but when i try to open a php(notepad file with .php extension) file from explorer(firefox) even after placing it in the htdocs folder in the Apache installation..the explorer gives and error The requested URL /phpinfo.php was not found on this server…plzz help me…and tell me whats wrong here


Nick
July 18, 2009: 4:43 pm

This does not work because when you restart the server it does not restart. These instructions aren’t very clear. This has mucked up my whole website. I suggest you do not use


Vineet Maheshwari
April 10, 2009: 4:14 pm

It is missing one trivial addition of index.php addition to the httpd.conf file. this was not allowing my apache to auto load index.php


Pete A
January 16, 2009: 9:44 pm

I recently installed apache and php on a Windows XP box and had the same error message ‘The Specified Module Could not be found’ as the above post.

My problem (and its solution) was due to the fact that I installed version 2.2 of Apache and had the line LoadModule php5_module “D:/php/php5apache2.dll” in my conf file. I changed this to LoadModule php5_module “C:/PHP/php5apache2_2.dll” and the problem was sorted.

The PHP install package includes this file - php5apache2_2.dll - as part of the download so you should already have it in your c:/php (or wherever you put php) folder.

May 31, 2008: 7:17 am

Hi
Thanks for the info
Short and good.

Well done ;-)

I have follow you instructions but I get an error:
The specified module could not be found.

My OS is Vista home premium.
Must say that the file: php5apache2.dll
was not part of the PHP package.
instead, I have: php5ts.dll

(Here is a good link to find that missing php5apache2.dll
https://kromann.info/download.php?strFolder=php5_1-Release_TS&strIndex=PHP5_1
)

This is the code lines from my httpd.conf
I have placed the lines at the end of the LoadModule list.
This line is the last one on the list:
#LoadModule vhost_alias_module modules/mod_vhost_alias.so

Then right bellow I have placed the 3 lines as you instructed:

LoadModule php5_module “php/php5apache2.dll”
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Please advice

Thanks for your help
Amit C.


Peter
February 24, 2008: 9:39 pm

Thanks,

That worked well.
Extra step to smooth things in Vista
I would add that in the htdocs folder (for those lazy folks who don\’t change the root directory to be something else), that changing the permission ability for USER makes it really simple to add/edit files
go to htdocs directory
right click and select \”Customize This Folder\”
select \”Security\” tab.
select \”Edit\” or \”Advanced\” to change the permissions for USER


Lok
December 18, 2007: 10:50 am

Awesome, thanks! this was the critical part I needed. Even book installation procedures were off base


rami
October 14, 2007: 11:28 pm

hi
does this config works on vista?
i download the latest php, but font contian the php5apache2.dll but i have the php5ts, can any1 tell me what to do..please


Anonymous
September 22, 2007: 4:16 am

Thank U very much..

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :