Posted by: songbard | November 11, 2008

PHP installation and setup.

Listed below are steps to install and configure PHP on windows. ( I was initially having problem with the same ).

1. Download PHP 5 from http://www.php.net/downloads.php. ( It is better to chose any zipped windows binary rather

than the  installer itself, as manual configuration is the best way in any case.)

2. Create a folder c:/php and extract files to the same. Take up php.ini-recommended and rename it to php.ini

and save it in the same folder.

3. Add  c:/php  to the  PATH  variable.  (  Control Panel->System->Advanced->Environment Variables->Edit Path

and restart the system.)

4. Time to edit php.ini. Open this in some ASCII editor ( eg. Notepad) and edit as below.

short_open_tag = On # tags like “<?” will be recognised as the start tag for a PHP script.

magic_quotes_gpc = On # If you want your input data to have the backslash (“\”) prefix.

The above should suffice for time being.

5. Configure Apache to load php modules/library.

Add the following to httpd.conf

LoadModule php5_module “c:/php/php5apache.dll” # If Apache 1.x series

LoadModule php5_module “c:/php/php5apache2.dll” # If Apache 2.0.x series

LoadModule php5_module “c:/php/php5apache2_2.dll” # If Apache 2.2.x series

AddModule mod_php5.c # Only if Apache 1.x

AddType application/x-httpd-php .php # Add under <IfModule mime_module> just before </IfModule>

AddType application/x-httpd-php .phtml # If .phtml support is required.

PHPIniDir “c:/php” # Add at the end of httpd.conf to indicate the location of php.ini.

6.  Create a simple php file index.php with the below content for test purpose

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo “Hello World! This is PHP calling\n”; phpinfo();?>
</body>
</html>

To see this as apache indexpage  edit DirectoryIndex  in apache httpd.conf  as  below:

DirectoryIndex index.php index.html #  Fails  over to index.html  if index.php is not there.

7. Restart Apache. In http://localhost contents of index.php should be displayed. (Not the code content of course!)

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: