Thursday, 26 March 2015

Web server ( Apache ) or http port 80



Web server ( Apache ) or http port 80

HTTP ( Hypertest Transfer Protocol ) => is the protocol for transfering hypertext documents thant makes the world wide web possible.
A standard web address eg. http://www.gmail.com is called URL ( uniform resouce locator ). The prefix (http) indicates its protocol.

http : 80
https : 444

=======================================================================
configure http web server

1> #yum install http -y

2> #vim /etc/http/conf/httpd.con

goto last line ( Shift + G)
copy 7 line of virtualhost entry 7yy and paste p

<VirtualHost 192.168.122.10:80 >
ServerAdmin webmaster@server.skynet.com  ------------------contact email id
DocumentRoot /var/www/html
ServerName  server.skynet.com ----------------------domain name
ErrorLog  logs/server.skynet.com
CustomLog  logs/server.skynet.com ---------------- access logs
</VirtualHost>

:wq

[ note : if configuration directory is /etc/httpd then complet logs path is /etc/httpd/logs/server.skynet.com ]

3> check configuration file syntax
#httpd -t
or
#service httpd configtest

4> host sample web page
#echo "welcome to linux" > /var/www/html/index.html

5> restore selinux context
#restorecon -R /var/www/html   ---------R - recursively

6> #service httpd restart

7> #chkconfig httpd on

=======================================================================
client side settings

set temporary dns as we do not have registered domain name

1> vim /etc/resolv.conf
search skynet.com
skynet.com 192.169.122.10

:wq

2> vim /etc/hosts  =========> temporary dns
192.168.122.10  server.skynet.com

:wq

Now you can access webpage in browser with below url
http://server.skynet.com/index.html

command line
#yum install elinks

#elinks http://server.skynet.com/index.html

===============================================================================

Extra :
add this entry in virtualhost section and restart httpd service after changes.

1> create aliase

Alias /kishor /var/www/html/kishor

#mkdir /var/www/html/kishor
#echo "welcome" > /var/www/html/kishor/index.html

2> Set redirect rule
do not add index page or create directory nasa

Redirect /nasa "http://server.example.com"

3> change start page
DirectoryIndex kishor.html

4> change httpd port
Listen 8080
add the port in virtual host line
<VirtualHost 192.168.122.10:8080>


access the web using port http://192.168.122.10:8080
================================================================================

Virtual Host  :

I> IP based : each host has separate IP address

1> add the IP on server
#ifconfig eth0:1 192.168.122.20

2> #mkdir /var/www/virtual
#echo "welcome to virtual" > /var/www/virtual/index.html

3>#restorecon -R /var/www/virtual

4> #vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.122.20:80>
ServerAdmin webmaster@www.example.com
DocumentRoot /var/www/virtual
serverName www.example.com

</VirtualHost>

5>#service httpd restart

recheck http://192.168.122.20

II> Name based virtaul host => different web on single IP address

1> #mkdir /var/www/mydomain
   #echo "welcome" /var/www/mydomain/index.html

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

<VirtualHost mydomain.com:80 >
ServerAdmin root@mydomain.com
DocumentRoot /var/www/mydomain
ServerName mydomain.com

</VirtualHost>

search the work
NameVirtualHost 192.168.122.10
            or
                *:80
                or
                www.skynet.com

3> #httpd -t

4> #service httpd restart

=========================================================================

No comments:

Post a Comment