Getting Apache 2.2 to work with PHP 5
I decided to install Apache 2.2 and also upgrade my PHP 5 and I thought it would be a straightforward process but in the end it wasn't for reasons I am going to explain below. I am not going to write a whole tutorial on installing Apache and PHP 5 because there are already some excellent tutorials around and the one from this site I found it to be very good.
What I will do though is to highlight the small changes I made to make Apache 2.2 work with PHP 5.
Assuming PHP is installed in the C:/php folder normally you would add the following lines to your Apache httpd.conf file:
LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# configure the path to php.ini
PHPIniDir "C:/php"
With Apache 2.2 I got an error on the LoadModule line. To resolve that error I had to download the latest stable release of PHP from the PHP Snapshots site. I downloaded the zip file for PHP 5.2 and this comes with the php5apache2_2.dll file.
In the Apache httpd conf file I then made changes to the LoadModule line as follows:
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# configure the path to php.ini
PHPIniDir "C:/php"
and this solved the problem. I prefer using the PHPIniDir directive because this means I
just maintain one copy of the php.ini file in C:/php folder in this case and I don't have to
copy another one to C:/Windows for example and this works fine for me.
Hi, People. I really like the site! Good job, nice logo... wealth of information on site and a nice design.
reply
Thanks for linking to the PHP Snapshots page. I've been struggling with Apache 2.2 for a few hours now, looking around the net, and this just saved me some more time. Thanks for that.
reply
If the info helped you and saved you a bit of time Bouken, then that's good to hear because that's the whole point of it.
reply
Thank you for this blurb...it got PHP working with Apache just like you said. :)
reply