Install Apache 2 (For Windows)
Apache HTTP Server, a popular industrial-strength web server, is provided free (with source codes) by the Apache Software Foundation (@ http://www.apache.org).
The mother site for Apache HTTP Server is http://httpd.apache.org. There are a few production versions available currently: 2.0, 2.2 and 2.4 (known as Apache 2). The legacy release 1.3 (Apache 1) is no longer supported.
At the time of re-writing (September 2014), the latest stable "source" release is 2.4.10 (you need to compile yourself). But the latest Windows "binaries" is 2.2.25 (32-bit version). Surprising, the AMP bundles such as WampServer 2.5 has Apache 2.4.9, XAMPP 1.8.3 has Apache 2.4.10?!
Download:
From Apache HTTP Server mother site http://httpd.apache.org ⇒ Choose the latest release (2.4.xx) ⇒ Download ⇒ Binaries ⇒ Win32 ⇒ Select the win32 with openssl, e.g., "httpd-2.2.25-win32-x86-openssl-0.9.8y.msi
".
Read the installation guide @ http://httpd.apache.org/docs ⇒ "Documentation 2.4/2.2" ⇒ "Reference Manual, Compiling and Installing".
Install: Run the downloaded installer.
- Provide your "domain", "server name" and "administrator's email".
For testing, enter "test.com
" for domain name, "localhost
" as the server name, and something for the administrator's email. We shall re-configure them later after the installation. - For testing, select "Only for for current user, on port 8000, when started manually".
- Choose "typical" installation.
- Select your installation directory. I shall assume that Apache HTTP Server is installed in the directory "
d:\myProject\apache2
". Hereafter, I shall denote the Apache installed directory as "<APACHE_HOME>
".
You shall get these sub-directories upon successful installation:
bin
: contains the binaries (or executables), such as Apache ("httpd.exe
") and Apache Monitor ("ApacheMonitor.exe
").conf
: contains the configuration files, such as the main configuration file "httpd.conf
".manual
: Apache HTTP server documentation. Start with "index.html
" or "index.html.en
".htdocs
: the default Apache's document root directory.
Configuring Apache 2
The configuration file for Apache HTTP server is called "httpd.conf
" (in directory "<APACHE_HOME>\conf
"). Browse through the configuration file and check these directives:
Listen
: The original "httpd.conf
" uses TCP port 80 (pre-assigned default for HTTP) for production and 8000 for testing. For testing, you may choose a port number between 1024 to 65535 (which is not used by an existing application - you can issue the command "netstat
" to check the existing connections). We shall run the Apache at port 8000.# Listen: Allows you to bind Apache to specific IP addresses and/or ports. Listen 8000
ServerName
: Set to your DNS hostname, or IP address (to find out your IP address, run command "ipconfig
"), or your computer name, or "localhost" (localhost is meant for local loop-back testing only, you can also use the localhost's IP address 127.0.0.1), followed by the port number chosen above.# ServerName gives the name and port that the server uses to identify itself. # If your host doesn't have a registered DNS name, enter its IP address here. ServerName localhost:8000
ServerRoot
: your Apache installed directory<APACHE_HOME>
.DocumentRoot
: the document root directory, i.e., home directory of the server. It is set to "<APACHE_HOME>\htdocs
" by default.DocumentRoot "<APACHE_HOME>/htdocs" # First, configure the "default" to be a very restrictive <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> # Document Root Directory <Directory "D:/bin/Apache2.2/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
Start/Shutdown Apache 2
Start the Server: The Apache executable is called "httpd.exe
" located in "<APACHE_HOME>\bin
". To display the help menu and check all the available options, start a CMD shell, and issue:
// change directory to <APACHE_HOME>\bin // Assume that Apache was installed in d:\myProject\apache2 prompt> d: > cd \myProject\apache2\bin // Display the help menu > httpd -h
Before you can run your server, you need to install the Apache Service by running the following command (You need administrator right to install services).
// Install Apache HTTP server as a Windows service
> httpd -k install
You can start the Apache by:
// Start the Apache HTTP server
> httpd -k start
Apache 2 provide a GUI Apache Monitor ("ApacheMonitor.exe
" in "<APACHE_HOME>\bin
"), which can be used to start/stop Apache, after the Apache service is installed. Apache monitor starts automatically with an icon in the task bar. Otherwise, run "ApacheMonitor.exe
".
After the Apache server is started, launch a web browser and access the server using URL:
http://ServerHostNameOrIPAddress:port
You could use "localhost" (IP address 127.0.0.1) for local loop-back testing if your browser runs in the same machine as the server.
http://localhost:8000
You could shutdown the Apache server either from the Apache Monitor or by running command:
> httpd -k stop
You could uninstall the Apache service by:
> httpd -k uninstall
You could remove the "Apache Monitor" from the "Startup" list.
If Things Go Wrong...
- Check the error message on the Apache's console.
- Check the log files at "
logs\errors.log
". - [TODO]
REFERENCES & RESOURCES
- Apache HTTP Server Mother Site @ www.apache.org
- Apache Documentation @ directory "
Manual
"