Apache
Apache is a powerful HTTP web server. A web server enables you to host specific files which can be downloaded via HTTP (Hyper Text Transfer Protocol) and displayed in a web browser. As well as displaying files Apache allows you to invoke programs on the server and have their output (HTML) sent to the web browser. Apache will allow us to execute our PHP scripts. When a request is made for a PHP script Apache will run the PHP executable and feed in the requested script. PHP will process the script and finally Apache will send the output of the PHP executable back to the client who requested it.
Download & Install
N.B: Before installing Apache, ensure that all other web servers installed on the system, such as IIS have been turned off, otherwise you will be unable to start the web server.
- The latest version of Apache can be found at http://httpd.apache.org/download.cgi. At the time of writing, the latest stable version of Apache was version 2.0.53, I will be downloading and using the Windows Installer version.
- After reading the license agreement and the introduction page you will be asked to enter some basic information. Unless you plan to access your server from other computers on your network or the Internet, enter “localhost” in the domain and server name fields. Ensure that the option to run Apache as a service on port 80 is selected, similar to MySql, this will allow Apache to start up with Windows.

- For the next two steps select the Typical install and confirm the directory you want Apache to be installed in. You are then ready to install Apache.
Testing the Installation
If you have Windows XP Service Pack 2 installed and the Internet Connection Firewall enabled, you may see a warning when Apache starts. This is because it is attempting to listen on port 80 for remote connections originating from any computer, whether it be on the local network or the Internet. I will show you how to disable this in the section on Securing the Apache Installation. To test the installation was successful, open your favourite web browser and enter the following URL:
http://localhost/
You should see the Apache start page. This page will contain a link to a local copy of the Apache manual.
Finding your way around
The
root installation directory C:\Program Files\Apache Group\Apache2 contains the following significant sub directories:
bin – this directory contains all Apaches executable files
cgi-bin – contains CGI programs / scripts which are executed by Apache.
htdocs – contains the web pages for your site
conf – contains Apaches configuration files. The main configuration file is called httpd.conf.
Securing the Installation
At this point we want to ensure that our web server is only accessible via the local machine and not to people from outside on the Internet. I strongly recommend that unless you are an advanced user, you follow these steps to prevent outside access.
- Open the web servers main configuration file, httpd.conf. A link to this file can be found in:
Start Menu -> Programs -> Apache HTTP Server -> Configure Apache Server -> Edit the httpd.conf Configuration File
- Find the line:
This line tells the server which TCP port to listen for HTTP connections on. At present is listens on all available network interfaces (i.e: modem, wireless, LAN, etc). We will change this to the loopback interface only, which has the name localhost. This ensures connections only originate from the PC itself:
Code:
Listen localhost:80
- Save and close the configuration file. For the changes to take effect you need to restart the web server. There is again a shortcut in the start menu to restart the web server:
Start Menu -> Programs -> Apache HTTP Sever -> Control Apache Server -> Restart