« Software Review: Aida32 | Home | Free Remote Assistance Now Available »
A Guide to installing Apache 2.2 and PHP 5 on Windows
By TheEmperor | March 9, 2008
If you’re looking to run your own website there’s no substitute for Apache. Here I’ll give a quick over view of the installation process for Apache and PHP on windows, then we’ll talk a little bit about the Apache config file and talk about what options you may want to adjust. The first thing you’ll have to do is download Apache and PHP and decide where you want to install them.
When you install Apache it will ask you a few questions, the domain name you are using, the server name, and the admin email address. If you are installing this on an internal network as a test you can make this essentially anything you want. You’ll notice that my example server is Testbox and my domain is techemperor.com. I chose to use testbox@techemperor.com as the email address so that I could easily distinguish the admin emails from the rest of my email. PHP will ask you where your apache config directory is, just browse to the Program Files/Apache Software Foundation/Apache2.2/Conf directory and click ok. Now you have Apache and PHP installed we can move on to configuring them.
First we’ll take care of the PHP configuration. You’ll have to do a little text file editing, but nothing major. First copy your PHP.ini file from the PHP installation directory (Program Files/PHP/php.ini) to your windows directory. Now fire up your favorite text editor and open the PHP.ini file you just copied. We’ll need to make a few changes here:
Find the doc_root line and make sure it points to Program Files/Apache Software Foundation/Apache2.2/htdocs next up find extension_dir and point it to Program Files/PHP. Now you’ll have to find any extensions (ex: php_curl.dll) you plan to use and uncomment their entries. Now find the SMTP= entry and set it to your mail server. This can be localhost if you are running a mailserver on the same machine as your Apache server, if not it should be your ISPs SMTP server. Now on the sendmail_from= line put a valid email address. I used the same testbox@techemperor.com email address that I used for Apache.
This is actually all you need for PHP to work. If you want to test it navigate to Program Files/Apache Software Foundation/Apache2.2/htdocs open up your favorite text editor and put this code in:
<?php
phpinfo();
?>
Now save the file as phpinfo.php and open up a web-browser. Type in http://localhost/phpinfo.php and press enter. You should see a page listing all of the information about your PHP install. If your needs are simple, like merely practicing website design or testing your websites before you put them up live this will generally be all you need to do. If your needs are more complex it may be time to delve into the arcane depths of the httpd.conf file.
If you know you need to edit the httpd.conf you usually know what you are changing and why as well so I’m only going to briefly touch on a few options. The LISTEN parameter changes the port that Apache runs on. By default it is set to 80 but you can change it to any port you want. This makes it possible to run multiple web servers on a single machine by assigning them to different ports. This is only needed if you require different versions or builds of Apache for each web server since virtual directories can be used to run multiple websites using one Apache server. You can also choose the IP address that Apache runs on in case you have say an internal website and an external website that run different builds of Apache on the same server.
Next you’ll see a very long list of modules. These modules all can be dynamically loaded and unloaded when Apache starts. Part of securing your server would be to unload any modules you were not using, and this is where you would normally add the command to load any custom modules you wanted Apache to use. Moving along there are a few options that you probably won’t need to adjust then there is the ErrorLog entry. Here you can change the directory that the logs are written to which is handy if you have a seperate partition or hard drive that you write the logs to. A little farther down is the sectionfor adding different MIME types to your Apache config. If you need to change how Apache handles certain file extensions this is the place to do it. Make sure you know what you are doing before making changes here. This is where you would add say .shtml or .xhtml extensions if you wanted Apache to read those and process them. This is also where you would enable global support for CGI scripts.
That takes care of the most commonly adjusted Apache parameters. If you want to change anything else you should read through the full Apache documentation first so that you know what you’re doing.
Topics: apache, apache configure, apache for windows, apache help, apache install, apache setup, helpdesk, php, web server |
Comments are closed.





