|[ Team LiB ]|
12.2 Running Apache
Installing and configuring the Apache web server is not much more difficult than installing an FTP server. Moreover, web servers tend to be more secure than FTP servers, so a web server may be a better way for you to publish files. Once your web server is up and running, other Internet users can view and download documents within the web-enabled directories on your Linux system. This section explains the installation and configuration of Apache, the most popular web server on the Internet.
12.2.1 Installing Apache
12.2.2 Configuring Apache
Configuring a web server can be as easy or as difficult as you choose. Like other web servers, Apache provides seemingly countless options. As distributed with Red Hat Linux, Apache has a default configuration that generally requires only a little tweaking before use. Apache's configuration files reside in the directory /etc/httpd/conf. For historical reasons that no longer apply, Apache has three configuration files:
However, the only configuration file that's currently used is httpd.conf. The easiest way to perform a basic configuration of Apache is with the Apache Configuration Tool. To configure Apache, choose Server Settings HTTP Server from the GNOME or KDE menu. The main configuration screen, shown in Figure 12-1, appears.
You should specify the Server Name and Webmaster email address. Unless your system has multiple network adapters or you want to run the web server on a nonstandard port (that is, a port other than 80), you don't need to modify the Available Addresses configuration item.
The Virtual Hosts tab, shown in Figure 12-2, lets you specify virtual hosts. Virtual hosting is a feature that lets you host multiple web sites with a single IP address. For example, both www.myfirstsite.com and www.myothersite.com could be hosted on the same system using a single IP address. However, virtual hosting is not compatible with HTTP 1.0 browsers.
The Server tab, shown in Figure 12-3, lets you specify the location of important files and directories and the user account and group used by Apache. You should not generally alter these configuration items.
The Performance Tuning tab, shown in Figure 12-4, provides access to configuration items that let you optimize Apache's performance. Unless your web server will see very heavy service, you should reduce the maximum number of connections. A value of 15 is more than appropriate for a personal web server.
If you're interested in exploring the many other configuration options provided by Apache, see the Apache manual, which resides in /var/www/manual. You can view the file with Links or another HTML browser. Also, see the Apache web site (http://www.apache.org), which includes a tutorial on Apache configuration.
12.2.3 Starting and Stopping Apache
Once you've configured your web server, you can start, stop, and restart it by using the Service Configuration Tool. You can also associate the httpd service with one or more runlevels, so that it starts automatically when your system boots. You can use Mozilla to test your web server by pointing Mozilla to the URL http://localhost/.
You should see a screen that resembles Figure 12-5.
Once you can access your web server locally, try accessing it from a remote computer. This should be as simple as forming a URL that includes the fully qualified hostname or IP address of your system (that is, the host and domain names), for example, http://mysystem.mydomain. However, bear in mind that you can reference your system by hostname only if its IP address is known to the DNS server or contained in the client's /etc/hosts file.
12.2.4 Creating Web Pages
Alternatively, users can create a public_html subdirectory within their home directory, for example, /home/joepublic/public_html. There, they can publish files that are web-accessible. To access such files, use a special URL that consists of a tilde (~) followed by the name of the user account. For example, http:// www.domain.com/~joepublic refers to the user joepublic's web directory. However, support for user publishing of web pages is not enabled by default. To enable it, edit the file /etc/httpd/conf/httpd.conf, changing the line:
UserDir enable all
Then, restart the httpd service. If you want to permit only specified users to publish web pages, replace the keyword all with a list of usernames, separating each from the next with one or more spaces:
UserDir enable billmccarty andyoram
You must also change the permissions of files and directories you want to be accessible via the Web. For the user joepublic's web pages to be web-accessible, the apache user account or group must have execute access to the directories /home, /home/joepublic, and /home/joepublic/public_html. Moreover, if automatic directory indexes are desired, the apache user account or group must have read access to the directory /home/joepublic/public_html. The files themselves must be readable by the apache user.
If you have trouble accessing web pages on your server, check Apache's log files, which you can view via the System Logs Tool. The log files may provide valuable clues to help you understand what's going wrong.
|[ Team LiB ]|