APACHE SERVER

 APACHE SERVER -

Apache is probably the most popular Linux-based Web server application in use. Once you have DNS correctly setup and your server has access to the Internet, you'll need to configure Apache to accept surfers wanting to access your Web site.

Port NO -              80

Package-              httpd
Daemon-              htpd
Scripts-                 /etc/init.d/httpd
Config file-           /etc/httpd/conf/httpd.conf
Default Document Root-      /var/www/html


There are two types of Apache configurations-

1) IP-Based and 
2) Name-based . (The DNS entry for both pooja.com and ashu.com website points to 192.168.0.254 ip-address.

Now Configure -

 1- IP Static
 2- Hostname

# setup              (Set Static IP) 
IP=192.168.0.254

# vim /etc/sysconfig/network              (Change hostname)

HOSTNAME=server-1.ashu.com

# yum install httpd* -y                          ( Install httpd Package)
                                                    
# rpm -qa httpd                                      (Check tha Package)
httpd-2.2.15-5.el6.x86_64
 

# /etc/init.d/httpd restart ;chkconfig httpd on                       (Restart httpd services)  
Stopping httpd:                                          [FAILED]
Starting httpd:                                            [  OK  ]

    test web server and show test page in firefox...
 

# firefox http://server-1.ashu.com

                 




# vim /etc/httpd/conf/httpd.conf                  (Open Configuration file and change Liast line)

<VirtualHost 192.168.0.254:80>
    ServerAdmin admin@server-1.ashucom
    DocumentRoot /var/www/html
    ServerName server-1.ashu.com
</VirtualHost>

# vim /var/www/html/index.html
 Hi this server-1.ashu.com

# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                              [  OK  ]

test web server .....
 
# firefox http://server-1.ashu.com
  



VIRTUAL HOASTING -

Using Apache Virtual Host, you can run several websites on the same server.
For example, I can run both ashu.com and pooja.com on a single physical server that has one Apache webserver running on it.



# vim /etc/hosts
192.168.0.254       server-1.ashu.com        server-1
192.168.0.253      server-2.ashu.com         server-2
 

# mkdir /var/www/virtual
# vim /var/www/virtual/index.html
 

"This is virtual web server"
 

# vim /etc/httpd/conf/httpd.conf 
 

990  NameVirtualHost 192.168.0.254:80                               (Uncoment this line)

<VirtualHost 192.168.0.254:80>
    ServerAdmin admin@server-1.ashu.com
    DocumentRoot /var/www/html
    ServerNameserver-1.ashu.com
</VirtualHost>
<VirtualHost 192.168.0.253:80>
    ServerAdmin admin@server-2.pooja.com
    DocumentRoot /var/www/virtual
    ServerName server-2.pooja.com
</VirtualHost>

 

# /etc/init.d/httpd restart                                                      (Restart Service)
Stopping httpd:                                          [  OK  ]
Starting httpd:                                            [  OK  ]
 

# firefox http://server-1.ashu.com
# firefox http://server-2.pooja.com  
                 
APACHE SERVER PASSWORD AUTHENTICATION-
                        

# vim /etc/httpd/conf/httpd.conf 
                                                             
<VirtualHost 192.168.122.1:80>
    ServerAdmin root@server-1.ashu.com 

     DocumentRoot /var/www/html
    ServerNameserver-1.ashu.com

 <Directory "/var/www/html">
AllowOverRide AuthConfig
</Directory>
</VirtualHost>

# vim /var/www/html/.htaccess
AuthName        "Basic Authentication"
AuthType        basic
AuthUserFile /var/www/html/.passwd
Require         valid-user

# useradd jojo
# passwd jojo
# htpasswd -cm /var/www/html/.passwd jojo
New password: 
Re-type new password: 
Adding password for user jojo
# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                              [  OK  ]
# curl http://192.168.0.254 -u jojo
Enter host password for user 'jojo':
 


"This is virtual web server"

 How to secure your web server-

# vim /var/www/html/.htaccess

AuthName    "any message}
AuthType    basic
AuthUserFile    /etc/httpd/conf/htpasswd
require user    om

:wq

#  htpasswd -mc /etc/httpd/conf/htpasswd om
redhat@123
redhat@123

# vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.0.100:80>
    ServerAdmin root@station1.example.com
    DocumentRoot /var/www/html
    ServerName station1.example.com
<Directory "/var/www/html">
options Indexes
AllowOverride Authconfig
</Directory>
</VirtualHost>
:wq

 

_____________________________________________________________________________________________
Click Back..                                Click Home..

https://docs.google.com/forms/d/1iNRZlJJO6rBFizzPcFmyOTEtfkdjhdVRmpM74IbiT3o/viewform