Friday, November 16, 2012

Apache web server




Apache  web server
The standard web server on Linux is Apache. The web server is the technology that receives requests from web browsers and servers up the requested web pages to those browsers.
Service profile
Service:  httpd
Package: httpd
Port no:80 (http)
Configuration file: /etc/httpd/conf/httpd.conf
                                 /etc/httpd/conf.d/SSL.conf
Script file: /etc/init.d/httpd
Daemons: httpd
Objective :for hosting the websites
Install the package
[root@webserver~]#yum install httpd* -y
Edit main configuration file
[root@webserver~]#vi /etc/hhtpd/conf/httpd.conf
#add the following lines at last
<VirtualHost 192.168.0.254>
ServerAdmin root@raju.com
ServerName www.raju.com:80
DocumentRoot”/var/www/html”   
ErrorLog logs/dummy-www.raju.com-error_log  
CustomLog logs/dummy-www.raju.com-access_log common
</VirtualHost>
:wq!
Now resovle the name locally
[root@webserver~]#vi /etc/hosts
192.168.0.254        www.raju.com
:wq!
Create html page
[root@webserver~]#vi /var/www/html/index.html
#****write html code in this and save *****#
:wq!
[root@webserver~]#chkconfig httpd on
[root@webserver~]#service httpd restart
[root@webserver~]#links www.raju.com
Virtual Web Hosting
Configuring multiple sites on  single web server is called virtual hosting
There are three different types of virual hosting are there .They are
Name Based: Hosting multiple sites on single ip is called as nambebased virtual hosting
IP Based: Hosting different websites by using different IP addreses i.e, we need individual ip address for each site
Port Based: Hosting the sites using port numbers other than the default port number.

Name Based Virtual hosting
Edit main configuration file
[root@webserver~]#vi /etc/hhtpd/conf/httpd.conf
Document Root “var/www/virtual”   #search for DocumentRoot and add this line below to it
NameVirtualHost 192.168.0.254       #search for NameVirtualHost and make it as seen here
#add the following lines at last
<VirtualHost 192.168.0.254>
ServerAdmin root@raju.com
ServerName www.raju.com
DocumentRoot”/var/www/virtual”   
DirectoryIndex   raju.html
ErrorLog logs/dummy-www.raju.com-error_log  
CustomLog logs/dummy-www.raju.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.254>
ServerAdmin root@koti.com
ServerName www.koti.com
DocumentRoot”/var/www/virtual”   
ErrorLog logs/dummy-www.koti.com-error_log  
CustomLog logs/dummy-www.koti.com-access_log common
</VirtualHost>
:wq!
Now resovle the name locally
[root@webserver~]#vi /etc/hosts
192.168.0.254        www.raju.com
192.168.0.254       www.koti.com
:wq!
Create html pages
[root@webserver~]#mkdir /var/www/virtual
[root@webserver~]#vi /var/www/virtual/raju.html
#****write html code in this and save *****#
:wq!
[root@webserver~]#vi /var/www/virtual/koti.html
#****write html code in this and save *****#
:wq!
[root@webserver~]#chkconfig httpd on
[root@webserver~]#service httpd restart
[root@webserver~]#links www.raju.com
[root@webserver~]#links www.koti.com

IP Based Virtual Hosting
[root@webserver~]#vi /etc/hhtpd/conf/httpd.conf
Document Root “var/www/virtual”   #search for DocumentRoot and add this line below to it
#add the following lines at last
<VirtualHost 192.168.0.254>
ServerAdmin root@raju.com
ServerName www.raju.com
DocumentRoot”/var/www/virtual”   
DirectoryIndex   raju.html
ErrorLog logs/dummy-www.raju.com-error_log  
CustomLog logs/dummy-www.raju.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.253>
ServerAdmin root@koti.com
ServerName www.koti.com
DocumentRoot”/var/www/virtual”   
ErrorLog logs/dummy-www.koti.com-error_log  
CustomLog logs/dummy-www.koti.com-access_log common
</VirtualHost>
:wq!
Now resovle the name locally
[root@webserver~]#vi /etc/hosts
192.168.0.254        www.raju.com
192.168.0.253       www.koti.com
:wq!
[root@webserver~]#mkdir /var/www/virtual
[root@webserver~]#vi /var/www/virtual/raju.html
#****write html code in this and save *****#
:wq!
[root@webserver~]#vi /var/www/virtual/koti.html
#****write html code in this and save *****#
:wq!

[root@webserver~]#chkconfig httpd on
[root@webserver~]#service httpd restart
[root@webserver~]#links www.raju.com
[root@webserver~]#links www.koti.com

Port Based Virtual Hosting
[root@webserver~]#vi /etc/hhtpd/conf/httpd.conf
Document Root “var/www/virtual”   #search for DocumentRoot and add this line below to it
#change the following lines
<VirtualHost 192.168.0.254:5000>
ServerAdmin root@raju.com
ServerName www.raju.com
DocumentRoot”/var/www/virtual”   
DirectoryIndex   raju.html
ErrorLog logs/dummy-www.raju.com-error_log  
CustomLog logs/dummy-www.raju.com-access_log common
</VirtualHost>
<VirtualHost 192.168.0.253:8080>
ServerAdmin root@koti.com
ServerName www.koti.com
DocumentRoot”/var/www/virtual”   
ErrorLog logs/dummy-www.koti.com-error_log  
CustomLog logs/dummy-www.koti.com-access_log common
</VirtualHost>
:wq!
Now resovle the name locally
[root@webserver~]#vi /etc/hosts
192.168.0.254        www.raju.com
192.168.0.254       www.koti.com
:wq!
[root@webserver~]#mkdir /var/www/virtual
Create html page
[root@webserver~]#vi /var/www/virtual/raju.html
#****write html code in this and save *****#
:wq!
[root@webserver~]#vi /var/www/virtual/koti.html
#****write html code in this and save *****#
:wq!

[root@webserver~]#chkconfig httpd on
[root@webserver~]#service httpd restart
[root@webserver~]#links www.raju.com
[root@webserver~]#links www.koti.com

Client Side configuration
[root@webserver~]#vi /etc/hosts
192.168.0.254        www.raju.com
192.168.0.253       www.koti.com

Open browser and enter the website name




Stay Connected With Free Updates!

Subscribe via Email

Follow me!

Leave Your Comment Below If You Like This Post

0 comments: