Web Serving Using Apache

[Home] [Resume] [Work Responsibilities] [Search Page] [IT Menu]

                    Summary - Quick Configuration

 

Web Serving Basics
The official Linux Web Server
The Basic Requirements
 

Installing Apache

Configuring Apache

Summary - Quick Configuration

 

Web Serving Basics


Web serving has become the premier calling card of the Linux operating system. While large companies don't need any help getting Linux to serve pages and most home users won't be serving web pages with Linux, many small businesses could use help getting a Linux web server off the ground. 

 

Apache Contents

 

The Official Linux Web Server?

There is no official "Linux Web Server" per se, but there is one program which, if such a title existed, would almost certainly hold it. Apache is the web server of choice for most Linux distributions, and indeed for Internet at large. Market research by any company in the industry invariably demonstrates that Apache is the top of its game, accounting for more web sites on the Internet than any other product, including Microsoft's IIS.

Since Apache is so prevalent on the Internet, and since it is so prevalent as well in the Linux community, we're going to use Apache here to get our web server running. Hold on to your boots!

 

Apache Contents

The Basic Requirements

Not much. Linux is fairly resource-friendly, so for a light traffic web server, you really don't need anything better than a 486 computer with 16 to 32 megabytes of memory. Smaller machines will work, but the smaller you go, the fewer simultaneous connections your web server will be able to handle, and the longer it will take to serve each page. If you need to be able to handle moderate traffic (several hits per minute), you'll probably want to get a slightly faster machine with more memory.

There is no real minimum on hard drive space for your web server; technically, you only need enough to hold Apache (just a megabyte or two) and the files and images you'd like your web server to serve up. Most Linux boxes are already well equipped to act as a personal or small business web server and won't need a great deal of additional storage.

The most important requirement for your web server is an Internet connection of some sort. Unfortunately, most home-based dial-up PPP accounts won't work. This is because most ISPs do not allocate specific resources to you when you sign up; instead, they have a "pool" of resources which are assigned as you dial in. This makes doing business cheaper for the ISP in the long run, but it also means that each time you connect, you may actually be communicating from a slightly different location (IP address) on the Internet.

Before you can run a web server, you'll need to get in touch with your ISP and discuss connectivity issues: whether or not they can compensate for dynamic IP numbers or perhaps assign a "static" IP address to your account. You may also want to work on name service issues with your ISP. Small businesses will generally want to use their ISP's name service and will thus only need to request a static IP and a domain name within their ISP's name space. All of these issues are outside the scope of this article and can better be discussed with your ISP anyway. If you find your ISP to be inflexible, unhelpful, or expensive, now may be the time for you to find a new one.

If you're expecting moderate traffic, you may even want to look into more expensive connection options like ISDN or xDSL. While these options are much more expensive than the more common modem-over-phone service, they can provide much greater bandwidth as well without having to stray into corporate-only cost levels. For the purposes of this article, we're going to assume that you'll be using a POTS (plain old telephone service) dial-up connection to your ISP.

 

Apache Contents

Installing Apache

Okay, we're ready to actually start working on the web server. Many Linux distributions will install and start Apache by default. To see if Apache is already running on your system, type:

  ps ax | grep httpd | grep -v grep

Even if there are no copies of Apache currently running, there is still a good chance that Apache has been installed for you, just not started when you booted. To start Apache type 

/var/lib/apache/sbin/http -f /var/lib/apache/conf/httpd.conf

If Apache hasn't been installed yet, there is a 99% chance that it was included with your Linux distribution. Get your CD out again, search for, and install the Apache package. To try to find what it's called, go to the directory where your CD is mounted, and type:

  find . | grep apache

Once you've located the package, you can install it with one of the following commands:

  rpm -i apachefile.rpm
  dpkg -i apachefile.deb

Apache Contents

Configuring Apache

Apache uses several configuration files to operate. Most of these will already be configured in sane ways by your distribution's defaults, but it can't hurt to review a couple of basics.

Most of the configuration you'll want to do will be in the httpd.conf , which can be located in several different places, depending on your distribution. Often, the file can be found  in /var/lib/apache/conf. Most of what you find in the file you should leave alone, but there are a few options you should change or notice:

 
ServerAdmin -- This option should be changed to reflect the e-mail address where runtime problems should be sent.
ServerRoot -- Don't change this, but make a note of it, since your log files will usually go here in the logs/ directory.
*Log* -- Options which begin or end with the word 'Log' (i.e. ErrorLog and TransferLog) since these all tell you about the logs Apache will keep. Make a note also of the comments before such options.
ServerName -- Change this to the domain name you and your ISP settled on. Note that it must be a valid name!
DirectoryIndex -- This is the "index" file for directories on your site (this will become more clear in a moment).
DocumentRoot -- This is the root directory for your web server content. For example, when a user points his or her browser to http://www.yourname.ISP.com, the file they will see the DirectoryIndex file in the DocumentRoot directory.
UserDir -- If there is more than one user account on your system (employees, for example), each can have a home page by creating a UserDir directory in their account. For example, an employee whose login was "jeff" would have a home page at "http://www.yourname.ISP.com/~jeff" which would (to him) reside in the UserDir directory in his account.

Once you've made note of these options and changed them where necessary, you should be able to start Apache (if it isn't already running) and serve up some web pages. The methods for starting Apache by hand and getting Apache to start at boot time vary from distribution to distribution, but you may be able to succeed with:

  /var/lib/apache/sbin/httpd -f  /var/lib/apache/conf/httpd.conf

To reinvoke apache when rebooting enter the following line into etc/rc.d/rc.httpd:

  /var/lib/apache/sbin/apachect1 start

Test the installation from another computer using either the text based lynx browser

    lynx apachehostname

or Netscape under X Window, by entering http://apachehostname or the IP address after the http://

Apache Contents

Summary - Quick Configuration

  1. Find the location of the httpd.conf file. Type find / -name httpd.conf
  2. Edit the httpd.conf.  Replace the entries against the sections labeled ServerAdmin and ServerName with your own machine hostname.
  3. Type in the following line to turn on apache.
    /var/lib/apache/sbin/httpd -f  /var/lib/apache/conf/httpd.conf
  4. To reinvoke apache when rebooting enter the following line into etc/rc.d/rc.httpd:
    /var/lib/apache/sbin/apachect1 start

  5. Test the installation from another computer using either the text based lynx browser lynx apachehostname or Netscape under X Window, by entering http://apachehostname or the IP address after the http://

     

     

 

  Apache Contents

 

 

 

The Basic Installation Installation and Configuration The Setup Program  
The GUI Configuration   Configuring the network Web Serving Using Apache 
Installing and configuring Samba Domain Name Server  Setup  
Mail Server Setup Berkeley Remote Command Setup