Configuring your Web Server

It's a good idea to configure your web server. Red Hat does provide a GUI tool, apacheconf, for configuring Apache, but it does not format the configuration file very well. Webmin (http://www.webmin.com - see Chapter 13) is an alternative web-based software that can be used to manage most of the Linux services, including the Apache web server. However, in this section we'll show you how to do some basic configuration by editing the httpd.conf Apache configuration file directly.

Try it Out: Configuring Your Web Server

We're going to configure the web server by adjusting a couple of the settings to suit our needs.

1. Launch the gedit text editor (by selecting Main Menu | Accessories | Text Editor), or your favorite text editor. Use it to open the file /etc/httpd/conf/httpd.conf.

2. Select Search | Find and use the resulting dialog to find the word ServerAdmin in the file. The first occurrence should be the ServerAdmin directive, which looks like this:

# ServerAdmin: Your server address, where problems with the server should be

# e-mailed. This address appears on some server-generated pages, such

# as error documents. e.g. [email protected] ServerAdmin [email protected]

As you can see, the configuration file describes this directive very well. Change the email address to your own email address, or an address that you may have set up for web site administration. For example:

# ServerAdmin: Your server address, where problems with the server should be

# e-mailed. This address appears on some server-generated pages, such

# as error documents. e.g. [email protected] ServerAdmin [email protected]

3. Now use the same technique to find the ServerName directive (you'll probably find that it's right after the ServerAdmin directive). Change this directive first by removing the leading # character. Then, if you have a registered DNS name, add it here (in place of the DNS name test.linux4biz.net, which I'm using here to demonstrate):

# ServerName gives the name and port that the server uses to identify itself.

ServerName test.linux4biz.net

The server name you specify should be a FQDN (because it will need to be resolved to an IP address by DNS). If you haven't setup a DNS, then you can enter the IP address allocated to the Linux server instead, like this:

ServerName 192.168.0.99

4. Save the httpd.conf file, and close it.

5. Restart the httpd daemon to reflect the changes. To do this, use Red Hat Services Configuration GUI, or the httpd command line script as described earlier in this chapter:

Now browse to http://localhost again, to check that the web server is still serving web pages. You should see the Apache Test Page that we saw earlier in this section.

There are many configuration settings that you can control via the httpd.conf configuration file. For more information, refer to the Apache web server documentation at http://httpd.apache.org/docs-2.0A

Was this article helpful?

0 0

Post a comment