Quick Starting the Apache Web Server

There are several ways to install Apache on your machine. If it wasn't installed during Red Hat installation, you can install it later from the CD-ROMs that come with this book. The binary package can also be downloaded from any Red Hat mirror site and is included on the official Red Hat distribution CD-ROM set.

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. The full source code distribution can be downloaded from www.apache.org/dist/ or from any Apache mirror site. You can select your closest mirror from www.apache.org/dyn/closer.cgi. Here is a quick way to get your Apache Web server started. From here, you'll certainly want to customize it to match your needs and your environment (as described in the next section).

Make sure that Apache is installed by typing the following from a Terminal window:

$ rpm -qa | grep apache apacheconf-0.8-4 apache-devel-1.3.20-8 apache-1.3.20-8 apache-manual-1.3.20-8

The version number you see may be different. You need only the Apache package to get started. I recommend apache-manual because it has excellent information on the whole Apache setup. The apache-devel package includes the apxs tool for building and installing Apache extension modules. The apacheconf package contains a GUI-based Apache Configuration tool.

You need to have a valid host name for your computer (for example, host1.handsonhistory.com). If you don't, 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 localhost, and uncomment it. It should appear as follows:

ServerName localhost

This allows you to work with your Web server from your local computer. To make it available to your LAN, you may want to use your IP address instead of localhost (for example, ServerName 10.0.0.15). To be a real Web server, you should get a real DNS host name.

Start the http 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 are ready to go. To have httpd start every time you boot your system, run the chkconfig httpd on command as root user.

To make sure that it is working, open Netscape (or other 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 the computer's hostname or IP address.

IWytpmiijmtmWwMi ifirw AftcWVA iimi Wtu<ku k<«wultil llf«iii»NWte FX«, n MM! ti« A; > W MOW MttU at OBI KM M

If you arc ihc adminiurutm of thit «vMir:

Y«tJM£MV«flftcMta*«»«M«racta* ra»Uc«0«}•(« WHiinijfwfcw. >mk r"»

U yw npihliwMH»Ui>i<i IMW ftn yw m Vw ww ft« »

rii—wnnil n il 1 ii !i I 111,I ...IK'l ku(i< A*rnMw««ui«Hiii«iv/Imm/M«»<

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

IWytpmiijmtmWwMi ifirw AftcWVA iimi Wtu<ku k<«wultil llf«iii»NWte FX«, n MM! ti« A; > W MOW MttU at OBI KM M

If you arc ihc adminiurutm of thit «vMir:

Y«tJM£MV«flftcMta*«»«M«racta* ra»Uc«0«}•(« WHiinijfwfcw. >mk r"»

U yw npihliwMH»Ui>i<i IMW ftn yw m Vw ww ft« »

rii—wnnil n il 1 ii !i I 111,I ...IK'l ku(i< A*rnMw««ui«Hiii«iv/Imm/M«»<

the URL, just use the name "localhost" (that is, http://localhost/ or http://localhost/index.html). In fact, it's best to fully test the configuration before making the server accessible on an unprotected network.

Replace the index.html file with your own home page in 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.

Was this article helpful?

0 0

Post a comment