If Apache wasn’t installed during the Fedora installation, you can install it later from the DVD 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).
It is possible for a new version of Apache to be released before an equivalent Fedora package is available. Or perhaps you’d prefer to customize the server’s compile-time options and build Apache directly from the Apache source code (SRPMS) that come with Fedora.
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 system-config-httpd-1.3.1-1 httpd-devel-2.0.52-2 httpd-2.0.52-2 httpd-manual-2.0.52-2
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 system-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:
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. (Refer to Chapter 25 for information on DNS and making a server public.)
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:
Change root@localhost to the e-mail address of your Apache administrator.
Start the httpd server. As root user, type the following:
# service 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:
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.
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 in the /var/www/html directory. Then you can continue to add your own content to that directory structure.
Now that your Web server is working (or at least, I hope it is), 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.
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 explains how tomake your Web or other server accessible. In particular, you need to open tcp port 80.