Installing PHP
Go to http://www.php.net/downloads.php and in the Windows Binaries section click the link for the PHP zip package, which should be something like PHP 5.2.9-1 zip package. Beneath that section is also a listing of several installer packages. I usually jump at the site of an installer package because they make it so much easier to install, but in this case do not use an installer package. The Windows installer configures things in such a way that it will probably cause you more trouble than it is worth. Trust me, don’t use the installer package. Although my instructions might appear daunting, it actually is not very difficult to install. That said, let’s begin.
When you click on the zip package link, it will take you to a page instructing you to choose a mirror site. Pick whichever mirror package is closest to you, and if there is more than one mirror site in your country, it does not really matter which one you pick.
When you click on the mirror site link, a File Download page will appear asking, “Do you want to open or save this file?” Note: If your PC doesn’t recognize .zip files, then download a zip program like WinZip, 7Zip, or another zip program (most programs are free). Once you are able, choose Save and you can save it to your C:\Temp folder or wherever you want. All you are saving at this point is basically a compressed file that you need to decompress/unzip later, so it doesn’t matter where you put it. When the download is complete, in the File Download screen choose the Open button, or if you selected the Open file button, double click on the new file (should be named something like php-5.2.9-1-Win32.zip and look like a stack of books) and your zip program should open up automatically. If it doesn’t, that probably indicates a problem with your zip program. I use a program called WinRAR and the following instructions are based on that program, but zip programs are all basically the same, so it should not be difficult to follow the instructions if you have another program. In WinRAR, select the folder named “..” and click the Extract to icon at the top of the screen. That will open a new Extraction path and options screen. Make sure you are on the General tab and in the box underneath Destination path, create a new folder named C:\php5 and click OK.
In the php5 folder you just unzipped, look for a file named php.ini-dist. Make a copy of the file and name it php.ini through either of the following methods:
1. Right click on php.ini-dist and choose Copy from the dropdown menu. Then, go to an open area of the same folder and click Paste. This will create a file named “Copy of php.ini-dist.” Rename this file “php.ini.”
2. Open php.ini-dist, go to File – Save-As, and in the screen that appears, enter php.ini in the File Name box and click Save.
Just to be safe, you should also make a backup copy. Just follow the previous step number one and just leave it titled Copy of php.ini-dist.
After you rename the file, double click it to open the file. You will notice that it is written in plain text (don’t be scared) and is really long.
Quick note: in the php.ini file, any of the lines that begin with a semicolon (;) are ignored and only the lines without a semicolon are accepted. Therefore, if you want to enable a line you would remove the semicolon and if want to disable a line you would add a semicolon. Just keep that in mind as you follow these instructions.
Hint: One trick to finding information in files like these is to type Ctrl+F, which brings up the Find command and it will search for whatever you type in the Find what field. The direction buttons tell it what direction to search. If you just opened the document, you can leave the Direction button as Down and it will begin looking from the beginning of the document down to the bottom.
One more note: in many of these steps I will explain how many lines down you need to navigate as a point of reference. These numbers may not be accurate depending on the program you use to read the file or if something changed in a different version, so don’t be alarmed if the numbers are not completely accurate.
1. Search for the following line:
error_reporting = E_ALL & ~E_NOTICE (Make sure you do NOT use a line with a semicolon in the beginning.)
and change it to
error_reporting = E_ALL
2. 19 lines down, make sure that the display_errors line is on. If it is set as Off, turn it back on. It should look like the following:
display_errors = On
3. 107 lines down, look for the following line:
register_globals = Off
This is the default setting. Do not change it NO MATTER WHAT. Turning it on gives malicious users the opportunity to mess with your site, so don’t do it.
4. 75 lines down, look for the following line in the Paths and Directories section (it’s easy to find because it has a ton of semicolons surrounding it to look like a box):
extension_dir = “./”
and change it to
extension_dir = “C:\php5\ext\”
This obviously tells PHP where to find your folder. If you chose a different folder name or put it in a different location, replace C:\php5 with the location you chose.
5. Scroll down until you reach the Dynamic Extensions section (easy to find like the last section), and slightly further down you will see a whole bunch of extension=php lines. These basically are extra features you can add to PHP if you know what you are doing. All of these lines have been disabled (because they have semicolons in front of them), and you can enable any of them by deleting the semicolon in the beginning of the line. We will enable four lines. I’m not sure what exactly these lines do, but I was told at some point to enable them and I suggest you do the same. The section begins with ;extension=php_bz2.dll and the lines are listed in alphabetical order.
Enable each of the following lines by deleting the semicolon in the front of the line:
;extension=php_gd2.dll
;extension=php_mbstring.dll
;extension=php_msql.dll (make sure you find this line exactly; there are several that look very close)
;extension=php_xsl.dll
6. Way further down (roughly 250 lines) look for the following line:
;session.save_path = “/tmp”
Delete the semicolon and change the information in the quotes to C:\WINDOWS\Temp
7. Save the file and close it.
Add PHP to startup procedure
Open your computer’s control panel by clicking the Start button in the bottom left corner and either going to Settings-Control Panel or straight to Control Panel.
Double click the System icon, click the Advanced tab, and click the Environment Variables button. In the bottom section of the screen that opens, highlight the Path line, and click the Edit button. This will open a small screen titled Edit System Variable. In the Variable Value field, go to the very end of the line and type a semicolon followed by the path of the PHP folder you created (in my case the path is C:\php5). Therefore, if you followed my instructions, the end of the line will look like ; C:\php5. Click OK.
With the Environment Variables screen still open, in the TOP section, click the New button, which will open a screen titled New System Variable. In the Variable name field, type PHPRC and in the Variable value field, enter the path of your PHP folder (in my case C:\php5.
Click OK in each of the boxes to close them. Windows will now be able to find the PHP files it needs when it starts up. Now we need to tell Apache how to work with PHP.
Configuring Apache to work with PHP
Now, you need to make some changes to the Apache configuration file so that it works with PHP.
Quick note: Apache uses forward slashes rather than the backward slashes we used with the php.ini file. Also, disabled lines have a # sign rather than a semicolon (;).
1. The Apache configuration file, titled httpd.conf, is located at C:\Program Files\Apache Group\Apache2\conf. Go to the file and double click it. If you happen to be prompted as to what program to open it with, use Notepad or any other text editor.
2. After opening the httpd.conf file, scroll down to the section with a whole bunch of LoadModule lines. At the end of the list, add the following line (make sure you do not put a # in the beginning):
LoadModule php5_module c:/php5/php5apache2.dll
If you installed php in a different folder than C:\php5, change that portion to the correct location, and don’t forget to use a forward slash rather than a backward slash. Note: if you have any spaces in your folder name, you need to put quotes around the path.
3. 54 lines down, look for the following line:
DocumentRoot “C:/Program Files/Apache Group/Apache2″
Each web server needs a folder to be used as the server root, and the server root is where you keep all your web files. Rather than keep them in the current location, most people suggest that you create a separate file. I created a folder named htdocs that I keep in my C: drive. If you choose to do that, go to your C: drive and create a folder named htdocs. Then, change the line indicated above so that it now looks like the following:
DocumentRoot “C:/htdocs”
Scroll down 25 lines and look for the following line:
<Directory “C:/Program Files/Apache Group/Apache2”>
and change it to
<Directory “C:/htdocs”>
4. 68 lines down, look for the following line:
DirectoryIndex index.html index.html.var
and add index.php and index.htm
This basically just tells web servers what to display if someone leaves out the http:// in the url (which almost everyone does now).
5. Much further down (around 450 lines) look for the section with a lot of lines beginning with AddType. After the last of those lines (probably following the AddType application/x-gzip .gz .tgz line), add the following line:
AddType application/x-httpd-php .php
Save the file and close it.
6. Now, you need to check that PHP is working. Create a file in a text editor like Notepad, or if you happen to have Dreamweaver, you can create it with that.
Add the following code to the new file:
<?php phpinfo(); ?> and save the file as phpinfo.php and save it in the htdocs folder you just created (C:\htdocs).
Restart Apache, following the instructions in the article Installing Apache. Open your browser, cross your fingers, and type http://localhost/. Hopefully, you will see a page with information about PHP. If you run into any problems, go through the instructions again and make sure you didn’t make any typos.
If you found this article to be helpful, please consider making a donation.

