Web servers provide the leading method for delivering information over an IP network. The Web is best known for providing information over the global Internet, yet it can just as effectively provide information to internal staff as it does to external customers. All but the smallest networks can benefit from a well-run web server, which can advertise products and offer support services to external customers, as well as coordinate and disseminate information to users within your organization. The Web is the single most effective tool for delivering on-demand information to end users.
Most Unix web servers are built with Apache software. Apache is freely available web server software with origins in the National Center for Supercomputer Applications (NCSA) web server, the first widely used web server. Because of these "ancient" roots, Apache has undergone years of testing and development. Because it is the most widely deployed web server software on the Internet, you will probably use Apache to build your Unix web server.
In this chapter, we focus on installing and configuring an Apache server. The large number of configuration options can make Apache configuration appear more complex than it really is. This chapter provides an example of a simple configuration to get Apache up and running quickly.
Our focus is configuration and administration of the service, not the design of the content provided by the service; web page design is beyond the scope of this book. If you're lucky, your organization has trained web designers; if you're not so lucky, you may be expected to take on this artistic task yourself. O'Reilly has books that can help you: try HTML and XHTML: The Definitive Guide, by Chuck Musciano and Bill Kennedy, or Web Design in a Nutshell, by Jennifer Niederst.
The Apache server software is bundled with many Unix systems. Frequently, Apache is installed as part of the initial operating system installation. For example, the initial installation of a Red Hat system presents a screen that allows the user to select the Apache software by clicking on an icon labeled Apache Web Server.
Frequently, users select the Apache server software even when they don't plan to run a web server. You might be surprised to find an Apache server installed and running on client desktop workstations. Try a ps test:
$ ps ax | grep httpd 321 ? S 0:00 httpd 324 ? S 0:00 httpd 325 ? S 0:00 httpd 326 ? S 0:00 httpd 329 ? S 0:00 (httpd) 330 ? S 0:00 (httpd) 331 ? S 0:00 (httpd) 332 ? S 0:00 (httpd) 333 ? S 0:00 (httpd) 334 ? S 0:00 (httpd) 335 ? S 0:00 (httpd) 2539 p1 D 0:00 grep http
The daemon that Apache installs to provide web services is the Hypertext Transport Protocol daemon (httpd). Use the process status (ps) command to check for all processes in the system, and the grep command to display only those with the name httpd. Running this test on a freshly installed system will show you if Apache is installed and running.
If Apache is running, start the Netscape web browser and enter "localhost" in the search box. Figure 11-1 shows the result on a sample Red Hat 7 system. Not only is Apache installed and running, it is configured and responding with a web page. Users of desktop Linux systems are sometimes surprised to find out they are running a fully functional web server. Of course, if you're the administrator of a web server system, this is exactly what you want to see -- Apache installed, up, and running.
If the Apache software is not installed on your system, you need to install the package. The easiest way to install optional software on a Linux system is to use a package manager. Several good ones are available. Most Linux systems support the Red Hat Package Manager (rpm), so we'll use that in the following example.
Use the Red Hat Package Manager to install needed software, remove unneeded software, and check what software is installed. rpm has many options for the developers who build the packages, but for a network administrator, rpm comes down to three basic commands:
You must know the name of a package to install it with rpm. To find the full name of the Apache package, mount the Linux CD-ROM and look in the RPMS directory. Here is an example from a Red Hat 7.2 system:
$ cd /mnt/cdrom/RedHat/RPMS $ ls *apache* apache-1.3.20-16.i386.rpm apacheconf-0.8.1-1.noarch.rpm
This example assumes that the CD-ROM was mounted on /mnt/cdrom. It shows that two Apache software packages are included in the Red Hat distribution: the web server software and a Red Hat configuration tool. Install apache-1.3.20-16.i386.rpm with this command to get the web server software:
# rpm -- install apache-1.3.20-16.i386.rpm
After installing the package, check that it is installed with this rpm command:
$ rpm -- query apache apache-1.3.20-16
Once the Apache package is installed, make sure the httpd daemons are started at boot time. On a Red Hat system, the script /etc/init.d/httpd starts the daemons. Use chkconfig or a similar command to add the script to the boot process. The following example adds the httpd startup script to the boot process for runlevels 3 and 5:
# chkconfig -- list httpd httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off # chkconfig -- level 35 httpd on # chkconfig -- list httpd httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
The first chkconfig command lists the status of the httpd script for every runlevel. The response shows that httpd is off for all seven runlevels, meaning that the script is not run. We want to start the web server at runlevel 3, which is the multiuser runlevel, and at runlevel 5, which is the default runlevel for this Red Hat system. The second chkconfig command does this. The --level argument specifies that runlevel 3 and runlevel 5 are affected -- note that the 3 and the 5 are run together with no intervening spaces. The httpd on argument says that the httpd script should be executed for those two runlevels. The last chkconfig command again lists the status of the httpd script for all runlevels. This time it shows that httpd will be executed for runlevel 3 and runlevel 5.
# /etc/init.d/httpd start Starting httpd: [ OK ]
Installing Apache on a Linux system is straightforward. It is often installed during the initial system setup; if not, it can usually be installed from the CDs that came with the system. Installing Apache on a Solaris system is just as simple because Solaris 8 also includes Apache as part of the operating system. If your Unix system does not include Apache, download it from the Internet.
Apache is available from http://www.apache.org in both source and binary forms. The Apache source is available for Unix systems in both compressed and zipped tarballs. You can download and compile the source, but the easiest way to get Apache is as a precompiled binary. Figure 11-2 shows just some of the versions of Unix for which precompiled httpd server daemons are available.
The binaries are listed by operating system. Assume you have a FreeBSD system. Click on the freebsd link, and you're presented with a long list of zipped tarballs. Each tarball relates to a different version of FreeBSD and contains an Apache binary distribution. Select the binary that is appropriate for your version of FreeBSD and download it to a working directory. Make a backup copy of the current daemon and extract the new daemon with tar. The software should now be installed and ready to run with the configuration files from your current configuration.
Copyright © 2002 O'Reilly & Associates. All rights reserved.