JumpStart I: Getting Apache Up and Running


To get Apache up and running, modify the /etc/httpd/conf/httpd.conf configuration file. "Directives I: Directives You May Want to Modify as You Get Started" on page 794 explains more about this file and explores other changes you may want to make to it.

Modifying the httpd.conf Configuration File

Apache runs as installed, but it is a good idea to add the three lines described in this section to the /etc/httpd/conf/httpd.conf configuration file before starting Apache. If you do not add these lines, Apache assigns values that may not work for you.

The ServerName line establishes a name for the server. Add one of the following lines to httpd.conf to set the name of the server to the domain name of the server or, if you do not have a domain name, to the IP address of the server:


ServerName example.com

or


ServerName IP_address

where example.com is the domain name of the server and IP_address is the IP address of the server. If you are not connected to a network, you can use the local-host address, 127.0.0.1, so that you can start the server and experiment with it.

When a client has trouble getting information from a server, the server frequently displays an error page that identifies the problem. For example, when Apache cannot find a requested page, it displays a page that says Error 404: Not Found. Each error page has a link that the user can click to send mail to the server's administrator. ServerSignature can specify that you want an email link on error pages and ServerAdmin specifies the email address that the server displays on error pages. Add these two lines to httpd.conf:


ServerAdmin email_address
ServerSignature EMail

where email_address is the email address of the person who needs to know if people are having trouble using the server. Make sure that someone checks this email account frequently.

After making the changes to httpd.conf, start or restart httpd as explained on page 787.

Testing Apache

Once you start the httpd daemon, you can confirm that Apache is working correctly by pointing a browser on the local system to http://localhost/. From a remote system, point a browser to http:// followed by the ServerName you specified in httpd.conf. For example, you might use either of these URI formats: http://192.168.0.16 or http://example.org. The browser should display the Red Hat/Apache test page. This test page is actually an error page that says there is no content. For more information refer to "Red Hat test page" on page 816.

If the server is behind a firewall, open TCP port 80 (page 788). If you are having problems getting Apache to work, see "Troubleshooting" on page 819.

Putting Your Content in Place

Place the content you want Apache to serve in /var/www/html. Apache automatically displays the file named index.html in this directory. Working as root (or as a member of the group you set up for this purpose [e.g., webwork]), give the following command to create such a page:

# cat > /var/www/html/index.html <html><body><p>This is my test page.</p></body></html> CONTROL-D


After creating this file, either refresh the browser if it is still running or start it again and point it at the server. The browser should display the page you just created.




A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net