If Apache wasn't installed during Red Hat installation, you can install it later from the CD-ROMs that come with this book. You will need the httpd package and optionally the httpd-manual package (named apache and apache-manual in earlier versions).
Note? |
It is possible for a new version of Apache to be released before an equivalent Red Hat package is available. Or perhaps you'd prefer to customize the server's compile-time options and build Apache directly from the source code. Download the full source code distribution from www.apache.org/dist/ or you can select your closest mirror from www.apache.org/dyn/closer.cgi. |
Here's a quick way to get your Apache Web server going. From here, you'll want to customize it to match your needs and your environment (as described in the section that follows).
Make sure that Apache is installed by typing the following from a Terminal window:
$ rpm -qa | grep httpd redhat-config-httpd-1.1.0-1.1 httpd-devel-2.0.45-14 httpd-2.0.45-14 httpd-manual-2.0.45-14
The version number you see may be different. You need only the httpd package to get started. I recommend httpd-manual because it has excellent information on the whole Apache setup. The httpd-devel package includes the apxs tool for building and installing extension modules. The redhat-config-httpd package contains a GUI-based Apache Configuration tool.
A valid host name is recommended for your Apache server (for example, abc.handsonhistory.com). If you don't have a real fully-qualified domain name, you can edit the /etc/httpd/conf/httpd.conf file and define the ServerName as your computer's IP address. Open the httpd.conf file (as the root user) in any text editor, search for the line containing ServerName new.host.name:80, and uncomment it. It should appear as follows:
ServerName new.host.name:80
To make the Web server available to your LAN, you can use your IP address instead of new.host.name (for example, ServerName 10.0.0.1). The :80 represents the port number (which is the default). For a public Web server, get a real DNS host name.
Add an administrative e-mail address where someone can contact you in case an error is encountered with your server. In the /etc/httpd/conf/httpd.conf file, the default administrative address appears as follows:
ServerAdmin root@localhost
Change root@localhost to the e-mail address of your Apache administrator.
Start the httpd server. As root user, type the following:
# /etc/init.d/httpd start
If all goes well, this message should appear: Starting httpd: [OK]. Now you're ready to go.
To have httpd start every time you boot your system, run the command as root user.
# chkconfig httpd on
To make sure that the Web server is working, open Mozilla (or another Web browser) and type the following into the location box and press Enter:
http://localhost/
You should see the Test Page for the Apache Web server, as shown in Figure 21-1. To access this page from another computer, you will need to enter your Apache server's host name or IP address.
Figure 21-1: Appearance of the Test Page indicates that the Apache installation succeeded.
Tip? |
It is not necessary to be connected to a network (or even to have a network connection) just to test the server or to view the files on your machine. Rather than specify the server's real name in the URL, just use "localhost" (that is, http://localhost/) from a browser on the same computer. In fact, it's best to fully test the configuration before making the server accessible on an unprotected network. |
The Test Page is actually an error condition, indicating that you haven't added any content to your Web site yet. To get started, you should add an index.html file that contains your own home page content to the /var/www/html directory. Then you can continue to add your own content to that directory structure.
Now that you have gotten your Web server to work (or at least, I hope you have), you should step through the next section. It helps you understand how to set up more complex Web server arrangements and protect your server from misuse. Stepping through that section will also help you troubleshoot your Web server, in case it isn't working.
Tip? |
If your Web server is accessible from your local host, but not available to others from your LAN or the Internet, you may need to change your firewall rules to allow greater access. Appendix C contains steps you can go through to make your Web or other server accessible. In particular, you need to open port 80. |