Previous Section
 < Day Day Up > 
Next Section


Apache Web Server

The Apache Web server is a full-featured free HTTP (Web) server developed and maintained by the Apache Server Project. The aim of the project is to provide a reliable, efficient, and easily extensible Web server, with free Open Source code made available under its own Apache Software License. The server software includes the server daemon, configuration files, management tools, and documentation. The Apache Server Project is maintained by a core group of volunteer programmers and supported by a great many contributors worldwide. The Apache Server Project is one of several projects currently supported by the Apache Software Foundation (formerly known as the Apache Group). This nonprofit organization provides financial, legal, and organizational support for various Apache Open Source software projects, including the Apache HTTPD Server, Java Apache, Jakarta, and XML- Apache. The Web site for the Apache Software Foundation is at www.apache.org. Table 22-1 lists various Apache-related Web sites.

Apache was originally based on the NCSA Web server developed at the National Center for Supercomputing Applications, University of Illinois, Urbana-Champaign. Apache has since emerged as a server in its own right and has become one of the most popular Web servers in use. Although originally developed for Linux and Unix systems, Apache has become a cross-platform application with Windows and OS/2 versions. Apache provides online support and documentation for its Web server at httpd.apache.org. An HTML-based manual is also provided with the server installation. You can use the Apache Configuration Tool to help configure your Apache server easily. It operates on any X Window System window manager, including GNOME and KDE. In addition, you can use the Comanche configuration tool. Webmin and Linuxconf also provide Apache configuration support.

Java: Apache Jakarta Project

The Apache Jarkarta Project supports the development of Open Source Java software; its Web site is located at jakarta.apache.org. Currently, the Jakarta supports numerous projects, including libraries, tools, frameworks, engines, and server applications. Tomcat is an Open Source implementation of the Java Servlet and JavaServer Pages specifications. Tomcat is designed for use in Apache servers. JMeter is a Java desktop tool to test performance of server resources, such as servlets and CGI scripts. Velocity is a template engine that provides easy access to Java objects. Watchdog is a tool that checks the compatibility of serverlet containers. Struts, Cactus, and Tapestry are Java frameworks, established methods for developing Java Web applications.

Linux Apache Installations

Your Linux distribution will normally provide you with the option of installing the Apache Web server during your initial installation of your Linux system. All the necessary directories and configuration files are automatically generated for you. Then, whenever you run Linux, your system is already a fully functional Web site. Every time you start your system, the Web server will also start up, running continuously. On most distributions, the directory reserved for your Web site data files is /var/www/html. Place your Web pages in this directory or in any subdirectories. Your system is already configured to operate as a Web server. All you need to do is perform any needed network server configurations, and then designate the files and directories open to remote users. You needn't do anything else. Once your Web site is connected to a network, remote users can access it.

Table 22-1: Apache-Related Web Sites

Web Site

Description

www.apache.org

Apache Software Foundation

httpd.apache.org

Apache HTTP Server Project

java.apache.org

Java Apache Project

jakarta.apache.org

Jakarta Apache Project

gui.apache.org

Apache GUI Project

www.comanche.org

Comanche (Configuration Manager for Apache)

www.apache-ssl.org

Apache-SSL server

www.openssl.org

OpenSSL project (Secure Socket Layer)

www.modssl.org

The SSL module (mod_ssl) project to add SSL encryption to an Apache Web server

www.php.net

PHP Hypertext PreProcessor, embedded Web page programming language

The Web server normally sets up your Web site in the /var/www directory. It also sets up several directories for managing the site. The /var/www/cgi-bin directory holds the CGI scripts, and /var/www/html/manual holds the Apache manual in HTML format. You can use your browser to examine it. Your Web pages are to be placed in the /var/www/html directory. Place your Web site home page there. Your configuration files are located in a different directory, /etc/httpd/conf. Table 22-2 lists the various Apache Web server directories and configuration files.

To upgrade your Apache server, either use the Red Hat upgrade tool (RHN) or look for recent Apache update files at the Red Hat FTP site. For binary versions for an RPM supported distribution Red Hat, you can download RPM packages containing the latest version of the Apache Web server, specially configured for your Red Hat Linux distribution. For Red Hat, the RPM packages for the Apache Web server are now named httpd instead of apache.

Alternatively, you can download the source code version for the latest Apache Web server directly from Apache and compile it on your system. You must decompress the file and extract the archive. Many of the same directories are created, with added ones for the source code. The server package includes installation instructions for creating your server directories and compiling your software. Make sure the configuration files are set up and installed.

Note 

If you are installing Apache from the source code, notice that versions of the configuration files ending with the extension .conf-dist are provided. You have to make copies of these configuration files with the same prefix, but only with the extension .conf to set up a default configuration. The Web server reads configuration information only from files with a .conf extension.

Table 22-2: Apache Web Server Files and Directories (RPM Installation)

Web Site Directories

Description

/var/www

Directory for Apache Web site files on Red Hat systems

/var/www/html

Web site Web files

/var/www/cgi-bin

CGI program files

/var/www/html/manual

Apache Web server manual

Configuration Files

 

.htaccess

Directory-based configuration files; an .htaccess file holds directives to control access to files within the directory in which it is located

/etc/httpd/conf

Directory for Apache Web server configuration files

/etc/httpd/conf/httpd.conf

Apache Web server configuration file

/etc/httpd/conf/conf,d

Directory holding module configuration files like ssl.conf for SSL and php.conf for PHP

Startup Scripts

 

/etc/rc.d/init.d/httpd

Startup script for Web server daemon

Application Files

Description

/usr/sbin

Location of the Apache Web server program file and utilities

/usr/share/doc/

Apache Web server documentation

/var/log/http

Location of Apache log files

Apache Web Server 2.0

Red Hat now uses Apache version 2.0 and up, which replaces the older 1.3. Apache 2.0 (see Red Hat Linux Reference Guide for conversion instructions). Most directives and features for Apache 1.3 still work on Apache 2.0. However, Apache 2.0 has introduced a new architecture that uses Multi-Processing Modules (MPM), which are designed to customize Apache to different operating systems. A Linux system would use the threaded MPM, whereas Windows would use the mpm_winnt MPM. To maintain compatibility with Apache 1.3 configurations, you would use the prefork MPM.

Apache 2.0 has adopted a much more modular architecture than 1.3. Many directives that once resided in the Apache core are now placed in respective modules and MPMs. With this modular design, several directives have been dropped, such as ServerType. Such directives deprecated in Apache 2.0 are noted in Table 22-3.

Note 

A selected MPM is usually integrated into Apache when it is compiled. Future Linux distributions of Apache should use the Linux/Unix default MPM, which is named "threaded."

Table 22-3: Apache Modules (Apache 2.0)

Module

Description

mod_access

Access control based on client hostname or IP address

mod_actions

Executes CGI scripts based on media type or request method

mod_alias

Maps different parts of the host file system in the document tree; performs URL redirection

mod_asis

Sends files that contain their own HTTP headers

mod_auth

User authentication using text files

mod_auth_anon

Anonymous user access to authenticated areas

mod_auth_db

User authentication using Berkeley DB files

mod_auth_dbm

User authentication using DBM files

mod_auth_digest

MD5 authentication

mod_autoindex

Automatic directory listings

mod_cern_meta

Support for HTTP header metafiles

mod_cgi

Invokes CGI scripts

mod_cgid

Invokes CGI scripts using an external daemon

mod_charset_lite

Configures character set translation

mod_dav

Distributed Authoring and Versioning, WebDAV HTTP extensions

mod_dir

Basic directory handling

mod_env

Passes environments to CGI scripts

mod_example

Demonstrates Apache API

mod_expires

Applies Expires: headers to resources

mod_ext_filter

Filters output with external programs

mod_file_cache

Caches files in memory for faster serving

mod_headers

Adds arbitrary HTTP headers to resources

mod_imap

Image-map file handler

mod_include

Server-parsed documents

mod_info

Server configuration information

mod_isapi

Windows ISAPI Extension support

mod_log_config

User-configurable logging replacement for mod_log_common

mod_mime

Determines document types using file extensions

mod_mime_magic

Determines document types using "magic numbers"

mod_negotiation

Content negotiation

mod_proxy

Caches proxy abilities

mod_rewrite

Powerful URI-to-filename mapping using regular expressions

mod_setenvif

Sets environment variables according to client information

mod_so

Support for loading modules at runtime

mod_spelling

Automatically corrects minor typos in URLs

mod_ssl

Interface for SSL encryption supported by OpenSSL

mod_status

Server status display

mod_userdir

User home directories

mod_unique_id

Generates unique request identifier for every request

mod_usertrack

User tracking using cookies (replacement for mod_cookies.c)

mod_vhost_alias

Support for dynamically configured mass virtual hosting

Starting and Stopping the Web Server

On most systems, Apache is installed as a standalone server, continually running. As noted in Chapter 20, in the discussion of init scripts, your system automatically starts up the Web server daemon, invoking it whenever you start your system. On Red Hat, a startup script for the Web server called httpd is in the /etc/rc.d/init.d directory. Symbolic links through which this script is run are located in corresponding runlevel directories. You will usually find the S85httpd link to /etc/rc.d/init.d/httpd in the runlevel 3 and 5 directories, /etc/rc.d/rc3.d and /etc/rc.d/rc5.d.. You can use the chkconfig command or the System V Init Editor to set the runlevels at which the httpd server will start, creating links in appropriate runlevel directories. The following command will set up the Web server (httpd) to start up at runlevels 3 and 5 (see Chapters 20 and 27 for more details on runlevels).

chkconfig --level 35 httpd on

On Red Hat, you can also use service command to start and stop the httpd server manually. This may be helpful when you are testing or modifying your server. The httpd script with the start option starts the server, the stop option stops it, and restart will restart it. Simply killing the Web process directly is not advisable.

service httpd restart

Apache also provides a control tool called apachectl (Apache control) for managing your Web server. With apachectl, you can start, stop, and restart the server from the command line. apachectl takes several arguments: start to start the server, stop to stop it, restart to shut down and restart the server, and graceful to shut down and restart gracefully. In addition, you can use apachectl to check the syntax of your configuration files with the config argument. You can also use apachectl as a system startup file for your server in the /etc/rc.d directory.

Remember, httpd is a script that calls the actual httpd daemon. You could call the daemon directly using its full pathname. This daemon has several options. The -d option enables you to specify a directory for the httpd program if it is different from the default directory. With the -f option, you can specify a configuration file different from httpd.conf. The -v option displays the version.

/usr/sbin/httpd -v

To check your Web server, start your Web browser and enter the Internet domain name address of your system. For the system turtle.mytrek.com, the user enters http://turtle.mytrek.com. This should display the home page you placed in your Web root directory. A simple way to do this is to use Lynx, the command line Web browser. Start Lynx, and type g to open a line where you can enter a URL for your own system. Lynx displays your Web site's home page. Be sure to place an index.html file in the /var/www/html directory first.

Once you have your server running, you can check its performance with the ab benchmarking tool, also provided by Apache. ab shows you how many requests at a time your server can handle. Options include -v, which enables you to control the level of detail displayed, -n, which specifies the number of requests to handle (default is 1), and -t, which specifies a time limit.

Note 

Currently there is no support for running Apache under xinetd. In Apache 2.0, such support is determined by choosing an MPM module designed to run on xinetd.



Previous Section
 < Day Day Up > 
Next Section
This HTML Help has been published using the chm2web software.