Tuesday, September 25, 2012

Install and configure Apache with PHP on Windows machine


Install and configure Apache with PHP on Windows machine :

Apache Installation :
1] Download the latest apache at http://httpd.apache.org/download.cgi

2] Run the installer apache_2.2.9-win32-x86-no_ssl-r2.msi.

3] First screen is the welcome note. Click Next.

4] Second screen is the licence agreement. Accept the terms in the license agreement, click Next.

5] Third screen, brief desription of the software. Next.

6] Server Information Dialogue will ask you for the following values:
Network Domain – name of your computer across a network connection. To know the Full Computer Name, right-click My Computer icon, choose Properties, click Computer Name Tab, and look for Full computer name. Or you can simply type localhost as its value.
Server Name – the same value with the Network Domain. Or localhost.
Admnistrator’s Email Address
Choose the radio button for All Users, on Port 80, as a Service. Click Next.
7] Select Typical for Set up Type. Next

8] Select Typical for Set up Type. Next

9] Destination Folder. Leave the default value, click Next.

10] Next screen is Ready to Install the Program. Click Install.

11] To Test Your Installation
Open a browser and point to
http://localhost or You should see the Apache Installation page.

PHP Configuration :

1] Download the latest php at http://www.php.net/downloads.php .

2] Unzip the contents of php-5.2.6-Win32.zip package to C:\PHP folder.

3] Find and rename the file php.ini-recommended to php.ini under PHP folder.

4] Open the file php.ini, look and uncomment the following directives (Click Edit > Find or Ctrl F) and save file.
[ Uncomment – remove the ; before a directive to activate it. ]
display_errors = on
register_globals = off
magic_quotes_gpc = on
extension_dir = /PHP/ext
session.save_path = /tmp Create a folder named TMP under the root directory (Drive C:)

--> 5] Attach PHP to Apache as a module. Open the Apache configuration file (C:\Program Files\Apache Software Foundation\Apache2.2\Conf\httpd.conf).
Search for LoadModule. Add this at the end:
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "C:/PHP"

Search for DirectoryIndex and add index.php.<IfModule dir_module>
DirectoryIndex index.php index.html
Add the following under <IfModule mime_module>:AddType application/x-httpd-php .php

6] Copy libmysql.dll file from your C:\PHP folder to the C:\WINNT\system32 directory or C:\Windows\System32 directory(Windows XP).

7] Restart Apache.
To Test PHP
Create phpinfo.php, type:<?php echo phpinfo(); ?>
Save as phpinfo.php in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\
8] Open a browser and point to http://localhost/phpinfo.php or .

No comments: