Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Setup Virtual Host

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 251
    Comment on it

    As the name suggested, Virtual Host is a technique to create a virtual URL of a website. For example on the local server we generally run a project like http://localhost/xyz but if you want to run this project like http://www.xyz.com on your local system. Virtual host will work for you.

    Please follow the below step to set virtual host:

    1) Please open /etc/hosts file. This file will appear like below:

    127.0.0.1 localhost 127.0.1.1 vivek-System-Product-Name

    The following lines are desirable for IPv6 capable hosts

    ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters

    Please add an another line on third row 127.0.1.1 xyz.com www.xyz.com

    Save this file and close

    2) Please open /etc/apache2/sites-available/default file. Copy the complete content of this file and paste this on the bottom of this file and make the changes as below:

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    
    ErrorLog ${APACHE&#95;LOG&#95;DIR}/error.log
    
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    
    CustomLog ${APACHE&#95;LOG&#95;DIR}/access.log combined
    
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/xyz
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/xyz>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    
    ErrorLog ${APACHE&#95;LOG&#95;DIR}/error.log
    
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    
    CustomLog ${APACHE&#95;LOG&#95;DIR}/access.log combined
    
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    

    3) Restart the server again. Now you can run xyz project link: http://www.xyz.com on your local system.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: