Download & Unpack
Download and install PHP from http://windows.php.net/download/, you should grab the newest VC6 x86 Thread Safe zip package (VC6 is on the bottom half of the page).
My file was named: php-5.2.7-Win32-VC6-x86.zip
Warning against PHP Installer I would NOT use the “PHP Installer” version. The Installer version (even though it’s larger) is missing some of the library/extension files you need for MySQL and it seems to have other random problems every time I try it. After multiple tries over several versions, my conclusion it is NOT worth the tiny bit of time it saves. So I highly recommend you use the PHP Zip Package version. Warning VC6 -vs- VC9 (PHP 5.2 -vs- PHP 5.3) PHP 5.3 is no longer available in a VC6 and you have to use old PHP 5.2 to get an officially Apache supported Window’s version (there’s warnings all down the left side of that download page). However, VC9 did work for me on Apache 2.2.17 with Windows7. However, I could not get VC9 (so PHP 5.3) to work on Windows XP.
- Unzip php. In my case, I unzipped to C:\php\
- Rename C:\php\php.ini-development to php.ini
Edit your php.ini
Open php.ini in a text editor and scroll down about halfway through the file and look for doc_root then change it to point to whatever your Apache DocumentRoot is set to. In my case: doc_root = “C:\public_html”
Scroll down about 7 more lines and change the extension_dir from ;extension_dir = “ext” to the location of the ext directory after you unzipped PHP. in my case: extension_dir = “C:\php\ext” (remove the ; from in front of it also)
Editing Apache Conf File
Using Notepad open httpd.conf (should be start-menu shortcut “Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File”). Either at the very beginning or end of the file add the following lines: (NOTE: be sure to change BOTH C:/php parts to the directory you installed your php to)
LoadModule php5_module "C:/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php"
[OPTIONAL] Editing Apache Conf File (part 2)
To get Apache to automatically look for an index.php, search httpd.conf for DirectoryIndex(about line 212) and add the files you want apache to look for when a directory is loaded (if it doesn’t find any of these files, it displays folder contents). Mine looks like:
<IfModule dir_module> DirectoryIndex index.php index.html default.html </IfModule>
Restart Apache if it is already running (if it doesn’t start or you get errors, use your Apache “Test Configuration” shortcut in the Start Menu to see why).
To test your PHP simply create a test.php file in your Apache “DocumentRoot” folder (C:\public_html\ in my case). In your test.php file, type these 3 lines and then load the file in your browser like http://localhost/test.php (you should get a whole long list of php variables, settings, etc):
<?php phpinfo(); ?>
One weird thing I have noticed about PHP is that it does not come with documentation of any kind. If you are a php developer/programmer, I suggest you download the documentation. Downloads can be found on http://www.php.net/download-docs.php and I personally recommend the “English – Windows HTML Help” (chm) version as the search is so handy, although they all contain the same information.