Friday, November 21, 2008

Configure Apache for PHP

Lets see how to configure Apache for PHP. Before proceeding with this post make sure you have installed PHP. Installing PHP was discussed in last post.

Following are the steps to configure apache2.2.10 for PHP5.2.6:

Step 1 :

Open the file 'httpd.conf' inside \Apache Software Foundation\Apache2.2\conf and add the following lines.

# ADDED FOR PHP HANDLING
------------------------------------------------------
LoadModule php5_module "C:\Program Files\Apache Software
Foundation\Apache2.2\php-5.2.6-Win32\php5apache2_2.dll"

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

The folder 'php-5.2.6-Win32' in the LoadModule line is the unzipped php installation file.

STEP 2 :

Restart
the apache server.


STEP 3 :

Create a php file 'index.php' with the following code.
------------------------------------------------------

phpinfo();
?>
------------------------------------------------------

And save it inside the folder 'htdocs' in /Apache2.2/ folder

STEP 4 :
Load the following URL in your browser -
http://localhost/index.php , you should get the php setting displayed to indicate that the php in properly parsed.

No comments: