Some of you have asked that the older version of the tutorial with PHP 4.3.x be put back up. I am putting it back up, but will no longer update it. You can still find it at PHP 4 page. However, I strongly recommend using the PHP 5 tutorial below.
Download & UnpackDownload 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.17-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 binary version (VC6 is needed for older versions of windows).
* My Windows 7 worked correctly with the newer VC9 (PHP 5.3).
* My Windows XP would not run VC9 (PHP 5.3).
If you are using Windows 7 or manually installed the C++ Runtimes (there's links on the left side of the PHP download page) then you can probably get away with using VC9/PHP5.3 versions. Otherwise I highly recommend sticking with the older VC6 (PHP 5.2) version.
- Unzip php. In my case, I unzipped to C:\php\
- Rename C:\php\php.ini-recommended to php.ini
VC9 Note VC9 will use the file php.ini-development instead of php.ini-recommended
Edit your php.iniOpen 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 = "./" to the location of the ext directory after you unzipped PHP. in my case: extension_dir = "C:\php\ext"
VC9 Note VC9 will have ;extension_dir = "ext" so make sure you remove the ; from in front of it also.
Editing Apache Conf FileUsing 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"
Note: If you installed the older Apache 2.0, instead of the above lines, you will need to use the lines listed on the bottom step of the Apache 2.0 tutorial.
[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>
TestingRestart 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(); ?>
Documentation SuggestionOne 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.