Tuesday, 19 March 2013

RHCSA: Deploy a default configuration HTTP server

Deploying a web server on an Red Hat system is very simple indeed. It's really only a matter of installing the required packages, ensuring the service is running at boot time and opening up the port on the firewall. Putting something interesting on there is up to you though...

As root, install the webserver package along with any dependencies:

 [root@mugwriter ~]# yum install httpd  
 Loaded plugins: product-id, refresh-packagekit, rhnplugin, security,  
        : subscription-manager  
 This system is receiving updates from Red Hat Subscription Management.  
 This system is not registered with RHN Classic or RHN Satellite.  
 You can use rhn_register to register.  
 RHN Satellite or RHN Classic support will be disabled.  
 rhel-6-client-rhev-agent-rpms              | 2.8 kB   00:00     
 rhel-6-desktop-rpms                   | 3.7 kB   00:00     
 Setting up Install Process  
 Resolving Dependencies  
 --> Running transaction check  
 ---> Package httpd.x86_64 0:2.2.15-26.el6 will be installed  
 --> Finished Dependency Resolution  
 Dependencies Resolved  
 ================================================================================  
  Package   Arch     Version        Repository         Size  
 ================================================================================  
 Installing:  
  httpd    x86_64    2.2.15-26.el6     rhel-6-desktop-rpms    821 k  
 Transaction Summary  
 ================================================================================  
 Install    1 Package(s)  
 Total download size: 821 k  
 Installed size: 2.9 M  
 Is this ok [y/N]: Y  
 Downloading Packages:  
 httpd-2.2.15-26.el6.x86_64.rpm                                                              | 821 kB   00:06     
 Running rpm_check_debug  
 Running Transaction Test  
 Transaction Test Succeeded  
 Running Transaction  
  Installing : httpd-2.2.15-26.el6.x86_64                                                                  1/1   
  Verifying : httpd-2.2.15-26.el6.x86_64                                                                  1/1   
 Installed:  
  httpd.x86_64 0:2.2.15-26.el6                                                                            
 Complete!  
 [root@mugwriter ~]#   

Once this has completed, check to see if the service has started:

 [root@mugwriter ~]# service httpd status  
 httpd is stopped  

As expected, it hasn't automatically been started up. I suspect this is for security reasons. Ok, let's start the service:

 [root@mugwriter ~]# service httpd start  
 Starting httpd:                 [ OK ]     

Let's make sure that the service runs automatically at boot time, otherwise we'll need to start it from the command line every time. We can use chkconfig to see which runlevels it is set to run at from boot and change as we see fit:
 [root@mugwriter ~]# chkconfig --list httpd  
 httpd          0:off     1:off     2:off     3:off     4:off     5:off     6:off  
 [root@mugwriter ~]# chkconfig httpd on  
 [root@mugwriter ~]# chkconfig --list httpd  
 httpd          0:off     1:off     2:on     3:on     4:on     5:on     6:off  
 [root@mugwriter~]#   
   

Right, we should be able to see the default apache webserver index page now. Launch a browser and go to http://localhost, you should see something like this:


Great, it's working! Some useful content to serve up might be nice though. You'll need to add your content to the /var/www/html directory on your system, starting with a new index.html.

If you want anybody other than users on your system to see this marvel of website design you're going to need to open up port 80 on your firewall. This is easy enough to do and you don't need to trouble yourself with iptables to do it. There are a couple of tools on a RHEL system for administering your firewall. if you are working at the CLI, you can use system-config-firewall-tui. If you are using a graphical interface, you can either launch  system-config-firewall from the command line or you can access it through the System > Administration > Firewall menu.




Put a tick in the box next to the www option to open up port 80 on the firewall and then click apply. I told you it was easy! Now you're all set to start serving up something a little more useful, perhaps a locally hosted  Red Hat software repository?






1 comment:

  1. I know the word of HTTP but i don't know the detailed of HTTP that which is very essential for me as well. Keep it up.
    Kallis

    ReplyDelete