Tuesday, May 3, 2011

Intalling the Default Apache HTTP Server on CentOS Step-by-Step


In this step-by-step walkthrough, you will install and configure the default Apache HTTPD server on CentOS 5.5.  This default web server is available for installation and configuration, after including the Server and Server GUI package groups during a CentOS 5.5 installation.  Total time to completion is approximately 15 minutes.  Good luck!


On CentOS, an Apache HTTPD server will likely already have been installed.  A simple check can verify this.  Open a terminal, and then enter the following:
httpd -v
This command will print the version and patch level of the installed httpd server. 

To find out more about this command and its arguments, enter: man httpd.

Though the Apache httpd web server is installed, it has not yet been started nor fully configured.  First, let's check to see what the current boot configuration for the httpd service is.  You'll use the chkconfig utility [1, 2].  At the terminal prompt, enter the following:
chkconfig --list httpd
This returns the httpd service status for each of the various runlevels [3].  Note the configuration for runlevels 2, 3, and 5.  This service needs to be started at boot for runlevels 2, 3, and 5.  Therefore, at the prompt, enter the following:
chkconfig --levels 235 httpd on
Runlevel 3 is multi-user text mode and 5 is multi-user graphic mode.  2 I'm not sure about: it's user-defined, but I'm not aware of the definition in this context.  Maybe a reader can assist.  Anway, after running this command, check the status again using the previous command.  You should see something like the following:

Now let's start the web service.  You'll use the service command.  You can use the graphical Services Configuration tool as well [4], but executing a command is much faster.  First, check it's status.  Enter the following command:
service httpd status
This returns that the service is stopped.

Now enter the following command [5]:
service httpd start
This starts the service.

TIP: to learn more about the service command, enter man service at the prompt.
Now to configure the Apache HTTP server service.  This can be done either using commands or using the graphical interface tool.  We'll use the tool here.  On the Gnome panel, go System > Administration > Server Settings > HTTP.

The HTTP tool appears [6].  On this tool, enter the fully qualified domain name.  Select the All available addresses... item listed in the Available Address list.

Click Edit.  The Edit an address... tool appears.  Select the Address option, and then enter the server's IP address.

Click OK.  The tool closes, and you are returned to the HTTP tool, with the revised address now listed.

All other settings can be left as default. Additionally, SSL is not addressed in this walkthrough.  Click OK.  A prompt will appear.

Click Yes.  Another prompt will appear.

Click Yes again.  The configuration directive changes you have made are saved to the Apache HTTP Server configuration file, /etc/httpd/conf/httpd.conf.  Now, restart the HTTP service.  Enter the following:
service httpd restart
This restarts the service, causing your configuration changes to be implemented.

Lastly, launch a web browser and then point it to your server IP:

Congratulations!  This completes this step-by-step walkthrough of installing and configuring the default Apache HTTP server onto CentOS 5.5.  Happy computing!


httpd dead but subsys locked

You may see this error after using the Services Configuration tool to restart the HTTP server.

As a check, exit and re-open the Services Configuration tool, and then scroll down and select the httpds service again.  If the status is now httpd (pid 21123) is running, you can ignore the subsystem lock error.

  1. Runlevel Utilities - Red Hat Linux Deployment Guide - Section 1.4.2
  2. chkconfig - Red Hat Linux 5 Deployment Guide - Section 16.5
  3. Runlevels - Red Hat Linux 4 Reference Guide - Section 1.4.1
  4. Services Configuration Tool - Red Hat Linux 5 Deployment Guide - Section 17.3
  5. Starting and Stopping httpd - Red Hat Linux 5 Deployment Guide - Section 23.3
  6. Apache HTTP Server Configuration - Red Hat Linux 5 Deployment Guide - Section 23.4

No comments: