NOTE: 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
http://www.ricocheting.com/server/php4.html, however I recommend using the tutorial below with PHP 5.1.
Download & Unpack
Download and install PHP from http://www.php.net/downloads.php, you should grab the newest 5.x.x Windows Binary zip package that will work on apache.
My file was named: php-5.1.1-Win32.zip
- Unzip php. In my case, I unzipped to:
e:\php\
- Rename e:\php\php.ini-dist it 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 = "e:\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 = "e:\php\ext"
Another thing you might want to change is you session path. Search for: session.save_path
and uncomment (remove the ; mark) and change it to an existing
directory. One reader pointed out the Window's temporary directory
works well. So session.save_path = "c:/windows/temp" or if you use Win2k maybe session.save_path = "c:/WINNT/Temp"
If you are going to be using your server for testing, i recommend (this
is optional) you search and change the error reporting to give you info
on any errors, notices, or bad coding. If you want to enable this type
of stuff, look for and change:
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
to
error_reporting = E_ALL | E_NOTICE | E_STRICT
Editing Apache Conf File
Using Notepad open e:\Apache2\conf\httpd.conf
(in the start-menu there should also be a "Edit the Apache HTTP Server
httpd.conf Configuration File" shortcut). Either at the very beginning
or end of the file add the following lines: (NOTE: be
sure to change the e:/php/php5apache2.dll to the directory you
installed your php to and change e:/php to the directory the php.ini
file is in)
LoadModule php5_module "e:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "e:/php"
Testing
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 and put these 3 lines into it. (When loaded in your browser, you
should get a whole long list of php variables, settings, etc):
<?php
phpinfo();
?>
Documentation Suggestion
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.