APACHE INSTALLATION

INSTALLATION 

Q. Host a website named as “first.com”

A. – Install “httpd” package.

Go to configuration file, copy last 7 lines and paste at the end also uncomment it. And add one more directive called “DirectoryIndex”

That section called “Virtual Host”, the query goes like this:

               1st “ServerName” and search for website name.

               2nd “DocumentRoot” and Looks for the path, where to find the files.

               3rd “DirectoryIndex” search for the name of the main file.

               (We can change the ‘name’ and ‘path’ of “ServerName”, “DocumentRoot” & “DirectoryIndex” as per our need.)

               CustomLog: To get the hit of your website

               ErrorLog: To get the error if website is not working


1st container is always a Master Container.

 

If any request came and VH i.e. Virtual Host is not present then the request is handled by GLOBAL Section.

Same as VH, if “ServerName”, “DocumentRoot” & “DirectoryIndex” is not present in Virtual Host (VH) then it will search in GLOBAL Section.

 

DocumentRoot of Global Section is: /var/www/html.


 

Practical

 

<SERVER>

1) # yum install httpd

 

2) # vim /etc/httpd/conf/httpd.conf

               <VirtualHost *:80>

               ServerAdmin webmaster@dummy-host.example.com

               DocumentRoot /opt/website_directory1

               ServerName first.com

               DirectoryIndex index.html   [WE ADD THIS EXTRA LINE]

               ErrorLog logs/dummy-host.example.com-error_log

               CustomLog logs/dummy-host.example.com-access_log common

               </VirtualHost>

:wq!

 

3) # mkdir /opt/website_directory1 && cd /opt/website_directory1

     # vim index.html

               This is first website

               :wq!

4) # httpd –t

               To test the configuration file.

               [To remove warning, Go to configuration file & uncomment the “ServerName” line]

 

5) # /etc/init.d/iptables stop

 

6) Disable SELINUX

     # vim /etc/selinux/config 

 

7) # /etc/init.d/httpd reload

 

<CLIENT>

1) # vim /etc/hosts

     <server-ip>     first.com

 

2) # elinks http://first.com/

 


Comments