A Cool Site for learning different

Sunday, August 21, 2011

Setting up Apache in Windows

Setting up Apache in Windows


This is a tutorial for setting up the Apache web server on a Windows computer. You will need to download Apache from http://www.apache.org before we can get started. It is a small download so you don't have to worry about the size. Make sure you download the .msi version because it will make installation easier. You may also need to download the Microsoft Windows Installer from http://www.microsoft.com


Double click the Installer file that you downloaded and leave all options at their default while you are installing it. Once it is installed restart your computer and you will now have the Apache Monitor program in your system tray.


Go to C:\Program Files\Apache Group\Apache2\conf and open the file called httpd.conf in notepad. By default the html documents are served from C:\Program Files\Apache Group\Apache2\htdocs. If you want to change it to something a bit easier to get to then find the line that starts with DocumentRoot and change the path inside the inverted commas to C:\www or whatever you want. A few lines down you will find a section that says you must change it to what you changed the DocumentRoot to. You must change this like it says.
A few lines down from that one is the Options. You must add Includes to it if you want to be able to use server side includes.
If you want to use cgi then you will need to change the ScriptAlias. Here is an example:
ScriptAlias /cgi-bin/ "C:/www/cgi-bin/"
Underneath it is another thing that must also be changed to what you have typed in above. Further down is AddHandler which must be changed to:
AddHandler cgi-script .cgi .exe .pl
AddOutputFilter must be changed to:
AddOutputFilter INCLUDES .html
Make sure that you save the file.
You must move your html pages to the folder that you specified in DocumentRoot. Make sure that your main page is called index.html.

Start it up

Click Start Menu -> Programs -> Apache HTTP Server 2.0.XX -> Start to start the server. To test if it works open Internet Explorer and type http://localhost in the address bar and press enter. If you did everything properly then you will see your index.html page displayed. If it displays an error with the number 500 then you didn't configure the server properly. If the error is 404 then you didn't rename your main page to index.html.