Webservers on Windows - Apache, Mysql and Php Installation
Step Five - Installing Php
The first step in installing php is unzipping the files. Many people recommend putting it in c:/php - but I think that causes as many headaches as it solves. It’s just as easy to put it in c:/program files/php. So unzip the contents and move the folder to the location you prefer. Next you need to add that location to your path variable. To do this, you need to find System Properties for your computer. Here are instructions for XP. You can either visit control panel->system settings or right click on my computer and choose properties. Choose the Advanced tab.

Click Evironment Variables

You may have more or less environment variables. Look in the lower box for the one called Path Click Edit

Add a semicolon to the end of the current path and add on your path to php - mine is c:/program files/php Click Ok until all the windows are closed.
There are two files we need to edit, httpd.conf which is the configuration file for apache, and php.ini, which is the configuration file for php. First you need to decide where your Document Root is going to be for your webserver. This is the place where you’ll store all the files for websites. The default is “C:/Program Files/Apache Group/Apache2/htdocs”. Head to Start->All Programs->Apache Http Server 2.0.55->Configure Apache Server->Edit the Apache httpd.conf Configuration File This will open up the apache configuration file in your text editor. Notice all the # signs? That means that line is a comment, and the program should disregard it.
Editing Apache Configuration
Scroll down until you reach a list of “Load Module” items. At the bottom of this list add LoadModule php5_module “c:\program files\php\php5apache2.dll” or LoadModule php4_module “c:\program files\php\sapi\php4apache2.dll”
It should look like this
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so
LoadModule php5_module "c:\program files\php\php5apache2.dll"
Notice that the path is c:/program files/php because that’s where I put my php files. Notice that I quoted the path - this is because I used backslashes and the path has a space in it. It’s good practice to quote paths on windows. I also removed the # from rewrite_module because that’s something I use a lot in my programming.
Scroll down some more until you come to DocumentRoot - this is the place where you’ll store your webpages. Simply place the absolute path to where you want your webpages to be stored, or keep the default if you like. If you change this value, you must also change the value of
#
# This should be changed to whatever you set DocumentRoot to.
#
<directory "c:/same/as/documentroot"&rt;
</directory&rt;
Continue down until you find the line
DirectoryIndex index.html index.html.var
and add index.php to that list.
Finally find the area with AddType declarations and add this to the end
AddType application/x-httpd-php .php
PHPIniDir “C:\program files\php”
Notice that your PHPIniDir may differ depending on where you put php.
Editing Php Configuration
Now you need to visit your php directory - mine is c:/program files/php. Copy php.ini-recommended and rename it php.ini. Then open it up in a text editor. Notice all the semi-colons? They work like the # did in the Apache file, they mean the line is a comment.
If you are NOT running a production server, you probably want to change display_errors to on and log_errors to off. By default php errors will be logged to your apache error log. You need to scroll down to the “Paths and “Directories” section. There are a lot of other useful settings, you can see the php manual for more information. For now we’ll only change the ones that windows needs to work properly. extension_dir needs to be set to the directory that holds all php extensions. In php5 this directory is name ext, in php4 it’s named extensions.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "c:/program files/php/ext"
Next you need to head down to the long list of Windows Extensions. In order to use the mysql or mysqli extensions you MUST have the line(s) extension=php_mysql.dll and/or extension=php_mysqli.dll uncommented. Finally move down to the [Session] module area and find session.save_path - it should be set to a location where apache can write - usually c:/temp although some use other locations.
Test Installation
First, restart your server. If you get an error, you may need to restart your computer - windows gets a little nutty over changing path variables. If you still get an error, try checking your syntax Head to Start->All Programs->Apache Http Server 2.0.55->Configure Apache Server->Test Configuration Often a silly typo can be the problem. Next create a blank file and name it info.php. Place one line in the file < ?php phpinfo()?> and put this file in your Document Root. Now head to http://localhost/info.php (or whatever your domain name happens to be). You should get a nice page with information about your php installation.

Congratulations - You’re done…kind of
One thing about open source projects is they fix bugs quickly and often. You don’t get once a month rolled updates. However, updating should be fairly painless. With apache - you’ll need to download the new version, then uninstall the old and reinstall the new. However, your original httpd.conf will be used so you don’t have to redo any settings. Mysql you can use windows installers to update right over the original programs. Php - stop the server, unzip the new files directly over the old files and restart the server. But make sure you update when security holes are fixed!

November 28th, 2005 at 9:35 am
We have had to copy libeay32.dll, libmhash.dll, libmysql.dll, ssleay32.dll, yas.dll from php directory to either the apache2 bin directory or windows system32 directory in order for php to find corresponding extensions.
November 28th, 2005 at 10:36 am
Then you didn’t read the directions carefully enough - add the path to the php directory to your path environment variable AND RESTART THE COMPUTER - I know a lot of people say you don’t have to restart after changing PATH but I can’t get that to work on windows XP pro - restarting fixes it. Also if you have problems with php_mysql.dll or php_mysqli.dll make sure the path to libmysql.dll comes BEFORE the path to your php dir in the path variable, otherwise the wrong libmysql.dll will get used.
July 10th, 2006 at 8:35 am
Do you know anything about adjusting the cpu utilization of apache under windows? Some data processing PHP scripts I’ve been running are executing rather slowly, and when I check the task monitor, the CPU usage never goes above 10%rnrnI’d like to see apache use 100% when running these scripts..
August 11th, 2006 at 9:48 pm
Have you a way to connect to PICK/UNIVERSE databases with php?
August 11th, 2006 at 11:02 pm
I don’t know that much about it but according to google theoretically you can connect to PICK/UNIVERSE with an odbc driver - so you’d have to install the driver in windows and create an odbc dsn and connect to it via php’s http://us2.php.net/odbc functions - but no, there is not a native way to connect to that database using php
December 18th, 2006 at 10:34 am
Hi! I setup SSL/TLS on apache 2.0.rnIts working fine apache only listen on 443 port for incoming connections. My question is:rnHow to config apache , for example when user type www.dome.com to automatic redirect him to port 443 and https connection. Now when i use www.domain.com he dont display anything because apache don listen on 80.rnCan you help me, please? Thanx