Configuring Apache web-server in RHEL6

Red Hat Enterprise Linux 6 is the latest release of Red Hat’s platform. It delivers advances in application performance, scalability, and security. With Red Hat Enterprise Linux 6, you can deploy physical, virtual, and cloud computing within your datacenter, reducing complexity, increasing efficiency, and minimizing administration overhead while leveraging technical skills and operational know-how. Red Hat Enterprise Linux 6 is an ideal platform to translate current and future technology innovations into the best value and scale for IT solutions.

Installing the Apache Web Server on RHEL
I am using only the console/terminal window (no GUI).
Apache does not get installed on RHEL 6 by default, just run the following command on console to verify it.

$ rpm –q httpd
You might get the output as package name with its version (which means it is installed. Or else, you might get “package httpd is not installed”, if it is the case then we need to install it. Let’s open terminal window and type the following command (and you need to be root).

$ su root
[root@localhost root]# yum install httpd –y
If you do not get any error message then, Apache got installed. Verify by typing following command.

[root@localhost root]# rpm –q httpd
Start Apache:Now, when we are sure it is installed, lets start it. Run the following command to check its status.

[root@localhost root]# service httpd status
If your output says that the service is not running execute the following command.

[root@localhost root]# service httpd start
You’ll get output wheter Apache got started or not. Now if you want that your httpd service starts everytime you login, we need to set it on your default runlevel, or on the runlevel you are in right now. To check this type the following command on your terminal window.

[root@localhost root]# who –r
Your output will be the runlevel you are in right now. Now lets say you are in runlevel 5 and want to set httpd service (Apache) to start evey time you are in runleve 5.[root@localhost root]# chkconfig –level 5 httpd on
Now lets verify our web-server. Lets launch Firefox (default web-browser) and type the address “127.0.0.1” (which is the loopback address) and press enter, you’ll get the default RHEL test page.
Configuration:
Now we need to configure the web-server. HTTPD.conf file keeps all the configuration entries for the web-server, we we’ll edit it. It is under /etc/httpd/conf folder. You’ll find lot of directives in this file. We’ll work on few of them. One of the directive is ServerAdmin. You can use your own email address where people can contact you. You can edit it as follows:

ServerAdmin admin@mysite.com
Then change ServerName directive.

ServerName mysite.com
Next we need to define DocumentRoot directive. It points to the location of all files related to the website.

DocumentRoot  /var/www/mysite.com
Just save the file and now we need to create ‘index.html’ and place inside /var/www/mysite.com (and we needmysite.com folder created for the same) folder.
Now all is done and we just need to restart Apache.

[root@localhost root]# service httpd restart
Launch the website.
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s