Most people rate quality and popularity together with price. On the web though, this is not the case. What is the most popular, highest quality web server available?
The Netscape-Enterprise server? Wrong.
Microsoft-IIS? Wrong again.
Apache? Bingo, and by a staggering amount.
According to Netcraft's December 1999 web server survey (http://www.netcraft.com/), apache is in the lead with 54.49%, followed by IIS at 23.78% and Netscape at 7.02%. Even though the latter two servers are heavily pushed by their companies, with lots of money backing them, Apache, a free, open source server, tops them all. So who runs it, just small web sites? Nope, guess again. Apache is such a powerful server that it runs sites such as Slashdot (http://www.slashdot.org/), The Financial Times (http://www.ft.com/), Linux.com (http://www.linux.com/) and JavaSoft (http://java.sun.com/), not to mention tons of other sites.
The Apache Project (http://www.apache.org/) started back in 1995 when a group of webmasters decided they needed a stable, powerful server for an upcoming site (one of these sites was http://www.hotwired.com/). At the time, the most popular server software available on the Web was developed by the National Center for Supercomputing Applications (NCSA). The developer, Rob McCool, left the organization and all development was stalled. It was at this point that webmasters were making their own extensions and bug-fixes for the server, but were not distributed in any way. The group of webmasters decided to co-ordinate the changes to the server, which later became known as 'patches'. This is how the Apache Server came to be, A-Patchy Server. A year after the release of the Apache Server, the small group of hackers had created the #1 server on the Internet.
Being able to view the source code for the server is one of the best parts of it. Not only can you modify and add features to the server yourself (providing you know C++, or Perl if using mod_perl), but the vast number of developers out there have made modules to add on to the server.
Due to it's popularity, we decided to create a group of tips and tutorials to help you install, configure/customize and optimize your Apache server. Since Apache is available for Unix and Windows, we will specify whether a tip is platform-specific.
Installing Apache and starting it up is generally thought to be a a grueling task, which it shouldn't. In fact, with these tips and tutorials, it should be quite easy for anyone. The installation of the Unix version of Apache is just like installing most other applications, you download the source, compile it, and voila! Windows is also easy for users, as it's just like installing another Windows application, as there is even a setup wizard.
Anyways, first we need a copy of Apache. Since it is relatively small (size range is 1-3 MB, it depends on the platform though), this should be a painless procedure. After that, it's just a matter of installing it. The tips for doing so will make this procedure as painless as possible.
To get Apache, obviously you have to go to their site at http://www.apache.org/. Proceed to the downloads section or find the closest Apache mirror to you to get your copy.
If you would like the Unix version of Apache, you would go through the well-named list of files and grab the gzipped copy (apache_1.3.9.tar.gz), or, for the Windows version, you would download the Windows binary setup file (apache_1_3_9_win32.exe).
Since installing the Windows version is the easiest, I will talk about that first. After the file is downloaded, just open it like usual and the setup wizard will open and install the server for you. Since Apache has just started making Windows versions, the code is not as stable as it is for Unix. Windows support is entirely experimental, and is recommended only for experienced users. The Apache Group does not guarantee that this software will work as documented, or even at all.
During the installation, you will be asked for
- the directory to install Apache into
- the start menu name
- the installation type. Typical installs everything except the source code. Minimum doesn't install the manuals or source code, and Custom allows you to 'customize' what is installed.
Now to the Unix version. Since you downloaded a tar ball, you have to decompress it. Simply type
tar -zxf apache_1.3.9.tar.gz
A directory called apache_1.3.9 will be created. You will have to go to this directory to proceed to the next step and compile the source code.
With all the source code neatly placed in this directory (and it's sub-directories), you will have to compile it to make it work. Here we will be using the GNU cc (gcc is the shortform) compiler to compile the source. It is free and distributed with most Unix operating systems. If it is not on your computer, download and install it from http://www.fsf.org/software/gcc/gcc.html.
Anyways, once in the apache_1.3.9 directory, from the prompt type
This will create a makefile with the default configuration. To change the configuration, you must edit apache_1.3.9/src/Configuration.tmpl before running configure. You can add/remove modules from the list, and many other options. Normally though, you just leave it alone, especially if this is your first try at installing Apache. For more information on editing the Configuration file, check out the README.configure file included with the distribution.
Two more command line commands to execute. Type
to compile the server, and
to put it in the proper directories. The default is /usr/local/apache/, though this can be changed in Configuration.tmpl.
Now that your Apache binaries have finally been installed, we can proceed on to how to use them.
After all of this work, we are now ready to start running Apache. There are obviously two methods for running it, one is for Windows and the other is for Unix.
Since Apache is just another Windows application, just go to the start menu, then the Apache Web Server program group. If you are not running Windows NT, just select "Start Apache as console app". If you are running Apache on NT though, you can hit the "Install Apache as Service (NT only)" option and Apache will be installed as a service on your computer. This means it will automatically start everytime NT is booted up.
To shutdown the server, there are two other options available in the start menu that should be self-explanatory.
To startup Apache in Unix, all you have to do is run httpd. This would look something like this
but this also depends on where you installed the binary. It will automatically use the configuration file it created on compilation called
httpd.conf. If you would like to use another configuration file, you can use the
/usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf
The Apache distribution does come with another method of starting/stopping/restarting Apache. The script is called apachectl. In the Apache src directory (
apache_1.3.9/src), type make at the prompt. You will see a few more files compiled. After make is done, go to the support directory (
apache_1.3.9/src/support), where you will find a bunch of new files created. There are a few helper scripts made now, including apachectl, htpasswd (used to make Apache passwords for protected directories), and rotatelogs (its use is explained later). There are a few other files, but these files are the most important.
Make a copy of these three files to your Apache binary directory. If you did not change the default settings, this would be located at
To start the server, use
There is also
available, obviously to stop or restart the server.
To have Apache start upon booting up your system, make a copy of apachectl in your startup directory (typically
Check it all out to make sure everything is working. From your browser, check out
http://localhost/ right afterwards. You will know if it worked or not if you see anything....
Phew! Now that everything works, it's time to configure our server.