Install PHP on Windows 7 is another post of Building Home Server series. In first post I have cover Apache installation on Windows 7. Today I’ll continue with PHP. I use PHP since 2000, PHP at that moment reach version 4.0 and I’m surprised with its movement. PHP widely adopted as one of standard for web based program and used by big company out there.
Download PHP & Preparation
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
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
Open command prompt of Windows 7
(type command in BOLD)
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
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.
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 :
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 :
You’ll see this result.
PHP successfully setup and configured to work with Apache.
In other post I’ll continue with MySQL installation on Windows 7.