Difference between revisions of "Configuring an RHEL 6 Based Web Server"

From Techotopia
Jump to: navigation, search
m (Text replacement - "<!-- Ezoic - BottomOfPage - bottom_of_page --> <div id="ezoic-pub-ad-placeholder-114"></div> <!-- End Ezoic - BottomOfPage - bottom_of_page -->" to "<htmlet>ezoicbottom</htmlet>")
m (Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">")
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<table border="0" cellspacing="0">
+
<table border="0" cellspacing="0" width="100%">
 
<tr>
 
<tr>
 
<td width="20%">[[Sharing Files between RHEL 6 and Windows Systems with Samba|Previous]]<td align="center">[[Red Hat Enterprise Linux 6 Essentials|Table of Contents]]<td width="20%" align="right">[[Configuring an RHEL 6 Postfix Email Server|Next]]</td>
 
<td width="20%">[[Sharing Files between RHEL 6 and Windows Systems with Samba|Previous]]<td align="center">[[Red Hat Enterprise Linux 6 Essentials|Table of Contents]]<td width="20%" align="right">[[Configuring an RHEL 6 Postfix Email Server|Next]]</td>
Line 137: Line 137:
  
 
<htmlet>rhel6</htmlet>
 
<htmlet>rhel6</htmlet>
 +
  
 
<htmlet>ezoicbottom</htmlet>
 
<htmlet>ezoicbottom</htmlet>
 
<hr>
 
<hr>
<table border="0" cellspacing="0">
+
<table border="0" cellspacing="0" width="100%">
 
<tr>
 
<tr>
 
<td width="20%">[[Sharing Files between RHEL 6 and Windows Systems with Samba|Previous]]<td align="center">[[Red Hat Enterprise Linux 6 Essentials|Table of Contents]]<td width="20%" align="right">[[Configuring an RHEL 6 Postfix Email Server|Next]]</td>
 
<td width="20%">[[Sharing Files between RHEL 6 and Windows Systems with Samba|Previous]]<td align="center">[[Red Hat Enterprise Linux 6 Essentials|Table of Contents]]<td width="20%" align="right">[[Configuring an RHEL 6 Postfix Email Server|Next]]</td>

Revision as of 20:03, 27 October 2016

PreviousTable of ContentsNext
Sharing Files between RHEL 6 and Windows Systems with SambaConfiguring an RHEL 6 Postfix Email Server


You are reading a sample chapter from the RHEL 6 Edition book.

Purchase the fully updated Red Hat Enterprise Linux 8 (RHEL 8) Edition of this publication in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book

Amongst the many packages that make up the Red Hat Enterprise Linux 6 operating system is the Apache web server. In fact the scalability and resilience of RHEL 6 makes it an ideal platform for hosting even the most heavily trafficked web sites. In this chapter we will explain how to configure an RHEL 6 system using Apache to act as a web server.


Contents


Requirements for Configuring an RHEL 6 Web Server

To set up your own web site you need a computer, an operating system, a web server, a domain name, a name server and an IP address.

The computer can be any system capable of running Linux. In terms of an operating system, we will, of course, assume you are using RHEL 6. As previously mentioned RHEL supports the Apache web server which can easily be installed once the operating system is up and running. A domain name can be registered with any domain name registration service.

If your ISP provides static IP addresses then you will need to associate your domain with your static IP address. This is achieved using a name server. Most domain registration services will provide this service for you.

If you do not have a static IP address (i.e. your ISP provides you with a dynamic address which changes frequently) then you can use one of a number of free services which map your dynamic IP address to your domain name. One such service is provided by http://www.dnsExit.com.

Once you have your domain name and your name server configured the next step is install and configure your web server.

Installing the Apache Web Server on RHEL 6

The current release of RHEL typically does not install the Apache web server by default. To check whether the server is already installed, open a Terminal window (Applications -> System Tools -> Terminal) and run the following command:

rpm -q httpd

If rpm generates output similar to the following, the apache server is already installed:

httpd-2.2.15-5.el6.x86_64

Alternatively, if rpm generates a "package httpd is not installed" then the next step, obviously, is to install it. This can be performed either from the command-line or using the Add/Remove Software tool. To use this tool, open the System -> Administration desktop menu and select Add/Remove Software. Enter your root password if prompted to do so. Select the Search tab and search for httpd. After the search completes the Apache HTTP Server should be listed in the search results. Click on the toggle next to the httpd server. Finally, click on the Apply button to begin the installation.

To install Apache from the command-line start a terminal window (Applications -> System Tools -> Terminal) and run the following commands at the command prompt:

su -
yum install httpd

Starting the Apache Web Server

Once the Apache server is installed, the next step is to verify that the server is running and, if it is not yet running, to start it.

The status of the server can be verified from the command-line or via the GUI Service Configuration tool. To check the status of the Apache httpd service from the command-line, enter the following command in a Terminal window:

/sbin/service httpd status

If the above command indicates that the httpd service is not running, it can be launched from the command-line as follows:

su -
/sbin/service httpd start

If you would like the Apache httpd service to start automatically when the system boots (for example when booting to runlevel 3), this can be achieved by running the following command:

/sbin/chkconfig --level 3 httpd on

For more information on runlevels refer to the chapter entitled Configuring RHEL 6 Runlevels and Services.

To configure the Apache service using the Service Configuration tool, select the System -> Administration -> Services menu option and scroll down the list of services until you find httpd. Select the item in the list and click on the Start button.

Testing the Web Server

Once the installation is complete the next step is to verify the web server is up and running. To do this fire up the web browser by clicking on the web browser icon in the top desktop panel and enter 127.0.0.1 in the address bar (127.0.0.1 is the loop-back network address which tells the system to connect to the local machine). The browser should load the Red Hat Enterprise Linux Test Page:


The RHEL 6 Apache test web page


Congratulations, you have now installed the web server and served up what will hopefully be the first of many web pages.

Configuring the Apache Web Server for Your Domain

The next step in setting up your web server is to configure it for your domain name. This is performed in the /etc/httpd directory. To configure the web server open a terminal window and change directory to /etc/httpd. In this directory you will find a number of sub-directories. Change directory into the conf sub-directory where you will find an httpd.conf file which contains the configuration settings for the Apache server.

Edit the httpd.conf file using your favorite editor using the su command to ensure you have write permission to the file. Once loaded, there are a number of settings that need to be changed to match your environment.

The ServerAdmin directive defines an administrative email address for people wishing to contact the webmaster for your site. Change this to an appropriate email address where you can be contacted:

ServerAdmin [email protected]

Next the ServerName and ServerAlias directives need to be defined so that the web server knows which virtual host this configuration file refers to:

ServerName myexample.com

Next, we need to define where the web site files are going to be located using the DocumentRoot directive. The tradition is to use /var/www/domain-name:

DocumentRoot /var/www/myexample.com

Next, create the /var/www/myexample.com directory and place an index.html file in it. For example:

<html>
<title>Sample Web Page</title>
<body>
Welcome to MyExample.com
</body>
</html>

The last step is to restart the apache web server to make sure it picks up our new settings:

su - 
/sbin/service httpd restart

Web Server and Firewall Issues

If your RHEL 6 system is configured to use a firewall, you will need to ensure that HTTP traffic on port 80 is permitted in order for external systems to be able to access your web server. Refer to Basic RHEL 6 Firewall Configuration for details on configuring RHEL Firewalls.

If the RHEL 6 system hosting your web server sits on a network protected by a firewall (either another computer running a firewall, or a router or wireless base station containing built in firewall protection) you will need to configure the firewall to forward port 80 to your web server system. The mechanism for performing this differs between firewalls and devices so check your documentation to find out how to configure port forwarding.

Once everything is configured it should be possible to enter the domain name of your web site into a browser anywhere in the world and access your web server.


You are reading a sample chapter from the RHEL 6 Edition book.

Purchase the fully updated Red Hat Enterprise Linux 8 (RHEL 8) Edition of this publication in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book



PreviousTable of ContentsNext
Sharing Files between RHEL 6 and Windows Systems with SambaConfiguring an RHEL 6 Postfix Email Server