Apache configuration/Web server configuration in RHEL 6

We are going to see Apache configuration/Web server configuration in RHEL 6 Linux.
Remember before configuring  web server, we must configure DNS/DHCP server to receive the correct traffic.

Required RPM’s:
1. Httpd
2. Httpd-devel

Install the required RPM’s using below commands.

#yum install http*  -> command will install the required rpm package including dependency.

Now configure the IP Address with 192.168.1.10 and check whether its configured properly or not. Without proper network configuration httpd service will wont start.

#ifconfig eth0 192.168.1.10 255.255.255.0
#ifconfig eth0

Now start httpd daemons and check the status

#chkconfig httpd on
#service httpd start
#service httpd status

Now configure Hosting:

We will host www.exampleweb.com to apache server and create index page under the root directory.

#mkdir –p /var/www/virtual/www.exampleweb.com/html
#vi /var/www/virtual/www.exampleweb.com/html/index.html

Just enter some text for testing purpose in index.html
<b> this is test page</b>

Bind system ip with www.exampleweb.com on /etc/hosts file. Usinf vi editor open the file and append like below.

#vi /etc/hosts
192.168.1.10 
www.exampleweb.com

Save and exit from the file using :wq

Now locate virtual host tag and remove # on apache configuration file (/etc/httpd/conf/httpd.conf)

#vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.1.10

Copy and paste the last seven line from the file and change as shown below.

<VirtualHost 192.168.1.10>
ServerAdmin
root@www.exampleweb.com
DocumentRoot /var/www/cirtual/www.exampleweb.com/html
ServerName
www.exampleweb.com
ErrorLog logs/dummy-www.exampleweb.com-error_log
CustomerLog logs/ dummy-www.exampleweb.com-access_log common
</Virtualhost>

Now restart the httpd service to effect the new configuration

#service httpd restart

Using links command will check the page

#links www.exampleweb.com
This is a test page
If you got out as whatever you have entered in index.html page than you have configured very well.