Monday, 13 April 2015

HTTP (httpd) Virtual Host Configuration in RHEL7/CentOS7


Virtual Hosts Configuration in Apache allows you to configure multiple web sites on a single IP Address.

In this tutorial, we will configure 2 web sites 'server2.mycompany.com' and 'www.mycompany.com' on a single IP Address.

Consider the following scenario:

HTTP Server IP Address: 192.168.122.3
                      Host Name: server2.mycompany.com

Server Configuration:

1)  Install httpd
[batul@server2 ~]$ sudo yum -y install httpd

2) Edit the file '/etc/httpd/conf/httpd.conf'.

                  ServerName server2.mycompany.com


3) Make Virtual Host Config file
     3.1) Copy sample file. 
[batul@server2 ~]$ cp /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d

     3.2) edit the file '/etc/httpd/conf.d/httpd-vhosts.conf'. Comment all the existing lines and  add the following.
             <VirtualHost *:80>
                 ServerName server2.mycompany.com  
                 DocumentRoot "/var/mysite"
           <Virtual Host>

             <VirtualHost *:80>
                 ServerName www.mycompany.com  
                 DocumentRoot "/var/publicsite"
           <Virtual Host>   

           <Directory "/var/mysite">
                  Require all granted 
           </Directory>           

           <Directory "/var/publicsite">
                  Require all granted 
           </Directory>           



4) Make directory for virtual hosts and change SELinux file label.
[batul@server2 ~]$ sudo mkdir -p /var/mysite
[batul@server2 ~]$ sudo chcon -R -t httpd_sys_content_t /var/mysite

[batul@server2 ~]$ sudo mkdir -p /var/publicsite
[batul@server2 ~]$ sudo chcon -R -t httpd_sys_content_t /var/publicsite


5) Create HTML files for both virtual hosts.
[batul@server2 ~]$ sudoedit /var/mysite/index.html

             <html>
             <body>
              <h1> Hello World  , mysite</h1>
              </body>
           </html>



[batul@server2 ~]$ sudoedit /var/publicsite/index.html

             <html>
             <body>
              <h1> Hello World  , publicsite</h1>
              </body>
           </html>


6) Check config file syntax errors
[batul@server2 ~]$ sudo httpd -t
[batul@server2 ~]$ sudo httpd -D DUMP_VHOSTS

7) Open HTTP (Port 80) in firewall
[batul@server2 ~]$ sudo firewall-cmd --zone=public --add-service=http --permanent
[batul@server2 ~]$ sudo firewall-cmd --reload

8)  Start httpd
[batul@server2 ~]$ sudo systemctl start httpd

9)  Enable on boot
[batul@server2 ~]$ sudo systemctl enable httpd


Client Configuration:

1)  Make entry in '/etc/hosts' if DNS Server is not configured

192.168.122.3        server2.mycompany.com www.mycompany.com

 2)  Install command-line browser 'elinks'
[shabbir@meru ~]$ yum -y install elinks

3) Browse web site
[shabbir@meru ~]$ elinks http://server2.mycompany.com

[shabbir@meru ~]$ elinks http://www.mycompany.com

1 comment:

  1. SSN FULLZ AVAILABLE

    Fresh & valid spammed USA SSN+Dob Leads with DL available in bulk & high credit 700+

    >>1$ each SSN+DOB
    >>3$ each with SSN+DOB+DL
    >>5$ each for premium fullz (700+ credit score with replacement guarantee)

    Prices are negotiable in bulk order
    Serious buyer contact me no time wasters please
    Bulk order will be preferable

    CONTACT
    Telegram > @leadsupplier
    ICQ > 752822040
    Email > leads.sellers1212@gmail.com

    OTHER STUFF YOU CAN GET

    SSN+DOB Fullz
    CC's with CVV's (vbv & non-vbv)
    USA Photo ID'S (Front & back)

    All type of Tools & Tutorials available
    (Carding, spamming, hacking, scam page, Cash outs, dumps cash outs)

    SQL Injector
    Premium Accounts (Netflix, Pornhub, etc)
    Paypal Logins
    Bitcoin Cracker
    SMTP Linux Root
    DUMPS with pins track 1 and 2
    WU & Bank transfers
    Socks, rdp's, vpn
    Php mailer
    Server I.P's
    HQ Emails with passwords
    All types of tools & tutorials.. & much more

    Looking for long term business
    For trust full vendor, feel free to contact

    CONTACT
    Telegram > @leadsupplier
    ICQ > 752822040
    Email > leads.sellers1212@gmail.com

    ReplyDelete