Installing Apache Web Server

Apache is the most popular web server used on the internet, and is available for free of charge from the Apache Software Foundation. It comes with all the tools you need to get started.

Installing Apache for Linux/UNIX/MacOS X
Installing Apache for Windows
Important Directories / File Layout

Linux / UNIX

Odds are good that Apache is already installed if you're running a recent version of UNIX. If it isn't installed, then it will most likely be available on the CD or other installation medium. Installing it is slightly different, depending on which kind of packaging system you use:

Redhat / Mandrake / Suse Linux
  1. Insert your CD
  2. Find the apache package on it using the file manager, or the command line as you like
  3. Double-click on the 'apache' package, or type the RPM command to install it
  4. Configuration files will be in /etc/httpd, while the documents and CGI programs will be in /var/www.
Debian / Corel Linux
  1. Run the following commands as the root user:

    apt-get update
    apt-get install apache
     
  2. Configuration files will be in /etc/httpd, while the documents and CGI programs will be in /var/www.
MacOS X

Apache comes with MacOS X, but the files are strewn about the system and renamed for some reason (to make it more user friendly?). Configuration files reside in /etc/httpd, while documents and CGI programs will be found in /Local/Library/WebServer.

Other UNIX (BSD, HP-UX, AIX, etc.)

You will want to get the source to Apache and follow the easy instructions that come with it to compile and install the software. The default directory for this type of installation will be /usr/local/apache.

Win32

Installing Apache under Windows is very easy. Go to a mirror of apache.org and look for the binaries/win32 directory. Download the latest no_src package (at the time this was written, the most current stable release was apache_1.3.23-win32-x86-no_src.exe).

Double-click on the downloaded file and choose a directory for it to install into. I chose C:\, so that I wouldn't have my HTML documents stored in the "Program Files" directory. The installer will ask a few questions about your hostname and domain, and it will ask if you want to run it as a service, which you should.

File Layout

 File Layout

Directory Contains
bin the program executables for the web server and tools to manage users and logs
cgi-bin the CGI programs that we will write
conf the configuration files for the Apache web server (httpd.conf) being the most important
htdocs all the documentation for the server
icons pictures used for default pages, such as directory listings
include files which allow for writing extensions of the server (modules) in C or C++
lib files which you must link into your module extension
libexec dynamic libraries that the server needs
logs the log files generated by the server go here, which are very important in CGI programming
modules dynamic libraries that are optional to the operation of the server; to see which are defined, look in the configuration file
proxy an optional directory which may contain proxy information/caches
src the source code to the Apache server so that you can rebuild it with custom modules (such as mod_perl or perlEx)

Pay particular attention to your installation and make certain you can find the following 3 very important directories:

  • cgi-bin
  • htdocs
  • logs

We will be spending almost all of our time in those three places.