Monday, December 19, 2011

Web Server Configuration


Introduction:-
Apache HTTP Server is a webserver developed and maintained by The Apache Software Foundation. Apache is the most popular web server, used on more than half of all Internet web servers. Most Linux distributions include Apache. Apache's advantages include its modular design, SSL support, stability and speed. Given the appropriate hardware and configuration it can support the highest loads. On Linux systems, the server configuration is usually done in the /etc/httpd directory. The most important configuration file is httpd.conf.

Requirement:-
  • Package = httpd
  • Service = httpd
  • Port No. = 80
  • Configuration File = /etc/httpd/conf/httpd.conf
Per quest:-
  • Configure IP = 192.168.1.1
  • Configure Virtual IP = 192.168.1.10 & 192.168.1.20
  • Configure Hostname = server.rootuser.in
  • Firewall must be disabled
[ Note = Here www.anup.com on 192.168.1.10 & www.shubham.com on 192.168.1.20 ]

1] Install required package for apache web server.
[root@server ~]# yum install http* -y

2] Edit the /etc/hosts file.
[root@server ~]# vi /etc/hosts [ Insert following lines at the end of file ]
192.168.1.1 www.rootuser.in www
192.168.1.10 www.anup.com www
192.168.1.20 www.shubham.com www
:wq

3] Restart the network service.
[root@server ~]# service network restart
[root@server ~]# chkconfig network on

4] Append the main configuration file.
[root@server ~]# vim /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.1.1
# Insert following lines at the end of file
<VirtualHost 192.168.1.1:80>
ServerAdmin root@rootuser.in
ServerName www.rootuser.in
DocumentRoot /var/www/html/rootuser
DirectoryIndex index.html
</VirtualHost>
<VirtualHost 192.168.1.10:80>
ServerAdmin root@rootuser.in
ServerName www.anup.com
DocumentRoot /var/www/html/anup
DirectoryIndex index.html
</VirtualHost>
#Following site is port based.
Listen 500
<VirtualHost 192.168.1.20:500>
ServerAdmin root@rootuser.in
ServerName www.shubham.com
DocumentRoot /var/www/html/shubham
DirectoryIndex index.html
</VirtualHost>
:wq

5] Now create the resources for website
[root@server ~]# cd /var/www/html
[root@server html]# mkdir {rootuser,anup,shubham}
[root@server html]# cd rootuser
[root@server rootuser]# cat > index.html
<b bgcolor=pink>Welcome to RootUser.in</b>
^d
[root@server rootuser]# cd .. | cd anup
[root@server anup]# cat > index.html
<b bgcolor=yellow>Welcome to anup.com</b>
^d
[root@server anup]# cd .. | cd shubham
[root@server shubham]# cat > index.html
<b bgcolor=green>Welcome to shubham.com</b>
^d
[root@server shubham]# cd

6] Start the httpd service
[root@server ~]# service httpd start
[root@server ~]# chkconfig httpd on

*Point your browser to following URL:
> www.rootuser.in OR 192.168.1.1
> www.anup.com OR 192.168.1.10
> www.shubham.com OR 192.168.1.20

[ If these website are opening without error then your Apache web server is working properly. ]