Pages

Monday, January 31, 2011

Srep by Step Guide Install PHP in Windows 7.........

Choose PHP Version
At time of writing this post, PHP version that used in production are version 5.2.xxx and 5.3.xx .
I recommend to download latest version of PHP 5.2.xxx due to majority of web hosting out there support PHP 5.2.xx.
Non Thread Safe or Thread Save
More link around the subject
  1. Wikipedia Thread Safety
  2. Difference between PHP thread safe and non thread safe binaries
Go to this URL and download ZIP version of Thread Safe PHP.


Save to My Document or other place.

Install PHP On Windows 7

Extract file to C:\php
Extract the file to C :\ and rename the folder to php.

Create php.ini file
Copy file php.ini-dist and rename that file back to php.ini
Confirmation window will appear confirm that if you change a file name extension, the file might become unusable.

On Windows 7 the icon for .ini file is special. You can use that as parameter for rename process.

Checking if PHP successfully Installed

Create phpinfo file
Create new file with notepad and save it to c:\php with name info.php
The content of that file
<?php
phpinfo();
?>
Open command prompt of Windows 7

(type command in BOLD)
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Users\LAPTOP>cd c:\php
c:\php>php -v
PHP 5.2.14 (cli) (built: Jul 27 2010 10:49:36)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
c:\php>php -q info.php
Bunch of result will show up. If you see that it means PHP successfully installed.

Configure PHP to work with Apache

Open apache httpd.conf by access “Edit the Apache httpd.conf Configuration File” under Configure Apache Server.

Notepad will open and start configure this file.
1. Click Edit and choose Find, type : LoadModule and click Find Next button.
Scroll down until you find “modules/mod_vhost_alias.so” line.
type :
LoadModule php5_module “c:/PHP/php5apache2_2.dll”
at type here as seen on the picture.

2. CTRL +F again and Find “AddType” .
Scroll down and type :
AddType application/x-httpd-php .php .php5 .asp .cgi
Under AddType application/x-gzip .gz .tgz

Note : .php5 .asp and .cgi means any file that has that extension will be execute as php file. You can add as many extension as you like.
3.  Configure the path to php.ini
Scroll to the bottom of file and type this :
PHPIniDir “C:/php”
Note : this line is directive that tell location of php.ini file.
Save the file by click File -> Save.
4. Restart Apache Service

Checking PHP – Apache integration on Windows 7

1. Copy info.php file in c:\php folder to c:\apache\htdocs

2. Open Web Browser and type :
http://localhost/info.php
You’ll see this result.

Congratulation.
PHP successfully setup and configured to work with Apache.

No comments:

Post a Comment

Write Your Experience and Suggestion Please.