Published on: Sunday 1st August 1999 By: Pankaj Kamthan
Apache began its life in 1995 as an enhanced version of the NCSA Web server through a series of "patches" and the result was an APATCHY server. Over the years Apache diverged from the original as many features were added to it. The main legacy in it are the configuration files, which have been kept for backward compatibility with the NCSA Web Server.
Since its inception, Apache has reached many landmarks. In 1997, Apache ports for Windows 95 and NT platforms were announced. In 1998, IBM announced support for the Apache project and a version of Apache is planned in its Internet commerce servers.
A detailed account of how Apache came about is available at www.apache.org. The current distributed version is 1.3.x, and forms the basis of this article.
The benchmark comparisons provided by Netcraft surveys show that the use of Apache has grown steadily over the last five years, and it is the most popular among the Web servers in use today. As of July 1998, Apache is run on over 1.2 million Internet servers.
Figure 1 illustrates the statistics on server share for the period August 1995 - May 1999. You may notice the (horizontal) symmetry indicating the rise of Apache and corresponding decline of NCSA over this period of time.
Figure 1. Netcraft Survey on Server Share.
A comparison of features of a large number of Web servers currently in use is available at WebServer Compare. A quick overview of features of Apache is available at webcompare.internet.com. A review of Apache by Server Watch is available at serverwatch.internet.com.
Apache offers various advantages to users, developers and Web administrators:
comp.infosystems.www.servers.unixor comp.infosystems.www.servers.ms-windows), and by companies who market commercial versions of Apache.
Apache is available as source as well as in binary formats for various operating systems. These sites list the current release, as well as, recent beta releases. Current distributed version is 1.3.6. Apache is mirrored world-wide. The best way to download Apache is to find the mirror closest to you.
There is an inherent trade-off between installing a binary and (compiling and) installing a source. A binary, although easier to install, may not necessarily be optimized for your system. A source is relatively more time consuming and difficult to install, as one has to follow a series of steps and make sure that appropriate versions of compilers are available on the system. However, the advantage of that is one can much better customize the server according one's needs.
In this section, we will give the details of compiling, installing and running Apache on UNIX and Windows, and briefly discuss the Apache port for Macintoshes.
By UNIX, we will mean UNIX and its variants, including Linux. All Apache administration on UNIX is command-line based.
Change into the
src directory of the Apache
distribution. Compiling Apache consists of the following three steps:
Configurationfile. A detailed account of the significance of Apache modules and their customization is given in Made to Measure : Apache Web Server Customization.
Configurescript. This generates a
Makefilefor use in step 3. (If this fails or you have any special requirements, you might need to edit one or more of the following options in the
EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES.)
You should now have a binary file called
httpd in the
src directory. A binary distribution of Apache will
supply this file.
Once you have the Apache binary, either as a result of compilation or from download, the next step is to install the program and configure it. Apache is designed to be configured and run from the same set of directories where it is compiled. We now focus our attention to editing the configuration files for the server.
Configuring Apache on UNIX
There are three central configuration files which contain various
directives that need to be set up. By default, these files are located
conf directory and are called
httpd.conf. The names of these files are taken to be
relative to the server root which is set by the
-d command line flag, or (on Windows only)
the registry. The files include helpful comments and description
of the directives. These files should be edited with care; failure to
set up these files correctly could lead to the server not working or
being insecure. They could be edited in the following order:
httpd.conf.This file contains directives that control the operation of the server daemon. It sets up general attributes about the server: the port number, the user it runs as, and so on.
srm.conf.This file contains directives that control the specification of documents that the server can provide to clients. This sets up the root of the document tree, special functions like server-parsed HTML or internal imagemap parsing, etc.
access.conf.This file contains directives that control access to documents.
The server also reads a file
mime.types containing MIME
document types. All these file names can be overridden by appropriate
On UNIX, the
httpd program is usually run as a (HTTP)
daemon which executes continuously, handling requests.
Starting the Server
To start the server, simply run
httpd. This will look for
httpd.conf in the location compiled into the code (by
/usr/local/apache/conf/httpd.conf). If this file
is somewhere else, you can give the real location with the -f
option. For example:
/usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf
If all goes well, this will return to the command prompt almost immediately which indicates that the server is now up and running. If anything goes wrong during the initialization of the server, you will see an error message on the screen.
If the server started properly, you can now use your browser to connect to the server. Once Apache starts running, it listens to port 80 (unless you changed the Port, Listen or BindAddress directives in the configuration files). To connect to the server, start a browser (on the same machine as the server) and enter the URL:
or if your host isn't connected to the Internet:
This should respond with a "test page" as shown in Figure 2, which is a sign of successful installation.
Figure 2. Apache Test Page.
When the server starts, it will create a number of child processes to
handle the requests. If you started Apache as the root user, the
parent process will continue to run as root while the children will
change to the user as given in the
If you want your server to continue running after a system reboot, you
should add a call to
httpd to your system start-up files
rc.local or a file in an
directory). This will start Apache as root. Before doing this, ensure
that your server is properly configured for security and access
restrictions. The process ID of this process is written to the file
httpd.pid in the log files
logs (unless configured otherwise).
Stopping the Server
A typical command to stop the server is:
kill -TERM `cat /usr/local/apache/logs/httpd.pid`
Restarting the Server
HUP signal to the parent process causes it to
kill off its children like in
TERM but the parent doesn't
exit. It re-reads its configuration files, and re-opens any log files. Then it spawns a new set of children
and continues serving pages.
There is also a script
src/support/apachectl which, after
a bit of customization for the system, can be used to start, stop, and
Apache comes bundled with, for example, the RedHat Linux distribution CD-ROM. It can be installed as a service during the installation of the operating system itself. The version on the CD, however, may not always be the latest. The easiest way to upgrade Apache on Linux to the latest version, is to use the RPM. There is an Apache RPM for Linux available and is maintained regularly.
To check whether Apache is running on your system, you can type the
in your browser. For details on the Apache httpd, you can type
on the command line.
Apache 1.3 is originally designed to run on Windows NT 4.0. An installation test was carried out successfully by the author on Windows 9x and NT 4.0 (Service Pack 4). Note that the binary installer only works on Intel processors. In all cases, TCP/IP networking is required.
Compiling Apache requires (at least) Microsoft Visual C++ 5.0 to be properly installed. We will not discuss the details of the compilation here.
When you run the Apache binary installer, you will be asked for:
This results in the following (if the default settings as used) to be attached in the Start menu:
During the installation, Apache will configure the files in the conf directory for corresponding to the installation directory. After installing Apache, you should further edit these files and adapt it to your needs.
Configuring Apache on Windows
Apache is configured using the files in the conf directory. These are the same as files used to configure the UNIX version, with a few different directives. The main differences are:
\Apache\modulesdirectory. To activate these, or other modules, the LoadModule directive must be used.
See the Apache documentation for all the available directives.
On Windows, Apache is usually run as a console application on Windows 9x, or as a service on Windows NT.
Running Apache on Windows as a Console Application
This option is available for Windows 9x and NT. To run Apache from a console window, select the Start Apache as console app option from the Start menu. This will open a console window and start Apache running inside it. The window will remain active until you stop Apache. To stop Apache running, either select the Shutdown Apache console app from the Start menu or enter Control-C in the Apache window. Figure 3 shows Apache running on Windows 9x/NT on console.
Figure 3. Apache running on Windows 9x/NT.
The Start menu icons can provide a simple interface for administering Apache. In some cases, however, it is easier to work from the command line. Table 2 of the Appendix gives the command line options for administering Apache.
Running Apache on Windows as a Service
This option is available on Windows NT only. This is the best choice if you want Apache to automatically start when you boot the machine, and to keep Apache running when you log off.
To start Apache as a service, you first need to install it as a service. Multiple Apache services can be installed, each with a different name and configuration. To install the default Apache service named "Apache", run the Install Apache as Service (NT only) option from the Start menu. Once this is done, you can start the "Apache" service by opening the Services window (in the Control Panel), selecting Apache, then clicking on Start. Apache should now be running in the background. You can later stop Apache by clicking on Stop from the Services window.
Once Apache starts running (either in a console window or as a service), it listens to port 80 (unless you changed the Port, Listen or BindAddress directives in the configuration files). To connect to the server, start a browser (on the same machine as the server) and enter the URL:
or if your host isn't connected to the Internet:
This should respond with a "test page" as shown in Figure 2.
The Start menu icons and the NT Service manager can provide a simple interface for administering Apache. In some cases, however, it is easier to work from the command line. Table 3 of the Appendix gives the command line options for administering Apache.
WebTen from Tenon Intersystems, is a commercial Apache-derivative Web server for Power Macintoshes. WebTen has a browser-based interface and supports standard Macintosh-style plug-ins, CGI, and SSL. Currently, WebTen for MacOS and iTools (previously WebTen v4.0) for MacOS X Server are available.
Apache comes equipped with log files (in the
directory) which contain information regarding the activity of the
httpd.pid. This process ID can be used for restarting and terminating the server.
error_log, on UNIX and
error.logon Windows 9x/NT. This file can be used for monitoring server activities, particularly start-up problems or other failed efforts by the server.
access_log, on UNIX and
access.log, on Windows 9x/NT. This file can be used for monitoring user access, and gathering basic information about the user's environment.
All these file names can be overridden by appropriate directives.
There are various problems that can occur in getting Apache to work. They are usually related to system or compiler incompatibilities, or improper settings in the configuration files.
If the server source doesn't compile on your system, it could be due to any one of the following reasons:
If a server binary doesn't install on your system, it could be due to any one of the following reasons:
error.log) file for additional information.
Depending on your platform, Usenet newsgroups comp.infosystems.www.servers.unix for UNIX and its derivatives or comp.infosystems.www.servers.ms-windows for Windows 9x/NT, can be quite helpful if you have installation/configuration questions. Both are frequently visited by experienced users and you can usually expect a quick response to your query.
Even though Apache is an extremely powerful server with a wide assortment of features, it does have certain, arguably minor, caveats:
The decision of choosing the "right" Web server is crucial for anybody who intends to have a presence and provide a service on the Web. Apache, with its numerous features, makes an excellent choice.
However, it must be said that running a Web server is relatively easy, but running a well-managed server isn't. A poorly managed server is an open invitation to a world of problems, which can involve anywhere from invasion of privacy and breach of security to the server crawling to a halt or even crashing abruptly. We will discuss some of these issues in future work.
I would like to thank Paul Wrigglesworth, Department of Geography, Concordia University, Canada, for his assistance in testing Apache installation on Windows NT.
These options are applicable to all Apache ports, including UNIX and Windows 9x/NT.
||Set the initial value for the ServerRoot variable to server root. This can be overridden by the ServerRoot command in the configuration file. The default is
||Define a name for use in in IfDefine directives. This
option can be used to optionally enable certain functionality in the configuration file,
or to use a common configuration for several independent hosts, where host specific
information is enclosed in
||Execute the commands in the file
config on startup. If config does not begin with a
||Process the given apache "directive" (just as if it had been part of a configuration file) before actually reading the regular configuration files.|
||Process the given apache "directive" after reading all the regular configuration files.|
||Run a single-process mode for internal debugging purposes only. (The daemon does not detach from the terminal or fork any children.) It should not be used to provide ordinary Web service.|
||Print the version of httpd and its build date, and then exit.|
||Print the base version of httpd, its build date, and a list of compile time settings which influence the behaviour and performance of Apache, then exit.|
||Give a list of directives together with expected arguments and places where the directive is valid, then exit.|
||Give a list of all modules compiled into the server, then exit.|
||Print a list of the httpd options, then exit.|
||Show the settings as parsed from the config file (currently only shows a breakdown of the vhost settings) but do not start the server.|
||Test the configuration file syntax (i.e., read all configuration files and interpret them) but do not start the server. If the configuration contains errors, display an error message and exit with a non-zero exit status, otherwise display "Syntax OK" and terminate with a zero exit status.|
Table 1. Apache General Command Line Options.
|apache||Start running Apache.|
|apache -f "\path_to\conf\file_name.conf"||Specify a configuration file. If a configuration file name with -f is not specified, Apache will use the file name compiled into the server, usually httpd.conf.|
|apache -k shutdown (or CTRL-C)||Signal Apache to stop. You will need to open another console window.|
|apache -k restart||Signal Apache to restart. This makes it re-read the configuration files. Any transactions in progress are allowed to complete without interruption.|
Table 2. Apache as a Console Application: Command Line Options.
|apache -i -n "service name"||Install Apache as a service. The default "service name", if one is not specified, is "Apache".|
|apache -u -n "service name"||Remove an Apache service.|
|apache -i -n "service name" -f "\path_to\conf\file_name.conf"||Install a service with a specific configuration file. If a configuration file name with -n is not specified, Apache will use the file name compiled into the server, usually httpd.conf.|
|apache -n "service name" -k start||Start running Apache.|
|apache -n "service name" -k shutdown||Signal Apache to stop.|
|apache -n "service name" -k restart||Signal Apache to restart. This makes it re-read the configuration files. Any transactions in progress are allowed to complete without interruption.|
Table 3. Apache as a Service: Command Line Options.