Tuesday, June 24, 2008

Integrate Apache 2.x with Php 5

Open {APACHE_DIR}/conf/httpd.conf
1) Enable mod rewrite by uncommenting or adding LoadModule rewrite_module modules/mod_rewrite.so

2) Add the following lines in the load module section
PHPIniDir "C:/Program Files/php"
LoadModule php5_module "C:/Program Files/php/php5apache2_2.dll"

3) Add php mime type
(a) Search for "IfModule mime_module" tag
(b) Add the following lines right after the "TypesConfig conf/mime.types"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php .html

(4) Allow full control to Apache's root folder that contains php files by creating or modifying (if one already exists) the <Directory> element for the root folder. Since the root folder for php is {APACHE_DIR}/htdocs folder itself on my machine, the directory entry looks like this:-

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all


(5) Test the setup. Create a new file called info.php under {APACHE_DIR}/htdocs folder. Copy & paste the following lines into info.php
<?php
phpinfo();
?>>


(6) Access info.php from the browser . The integration with Apache is successful if you see a page that lists information about the php environment installed on your machine.

No comments: