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
    • 269
    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

    1. DocumentRoot /var/www
    2. <Directory />
    3. Options FollowSymLinks
    4. AllowOverride All
    5. </Directory>
    6. <Directory /var/www/>
    7. Options Indexes FollowSymLinks MultiViews
    8. AllowOverride All
    9. Order allow,deny
    10. allow from all
    11. </Directory>
    12.  
    13. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    14. <Directory "/usr/lib/cgi-bin">
    15. AllowOverride None
    16. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    17. Order allow,deny
    18. Allow from all
    19. </Directory>
    20.  
    21. ErrorLog ${APACHE&#95;LOG&#95;DIR}/error.log
    22.  
    23. # Possible values include: debug, info, notice, warn, error, crit,
    24. # alert, emerg.
    25. LogLevel warn
    26.  
    27. CustomLog ${APACHE&#95;LOG&#95;DIR}/access.log combined
    28.  
    29. Alias /doc/ "/usr/share/doc/"
    30. <Directory "/usr/share/doc/">
    31. Options Indexes MultiViews FollowSymLinks
    32. AllowOverride None
    33. Order deny,allow
    34. Deny from all
    35. Allow from 127.0.0.0/255.0.0.0 ::1/128
    36. </Directory>

    ServerAdmin webmaster@localhost

    1. DocumentRoot /var/www/xyz
    2. <Directory />
    3. Options FollowSymLinks
    4. AllowOverride All
    5. </Directory>
    6. <Directory /var/www/xyz>
    7. Options Indexes FollowSymLinks MultiViews
    8. AllowOverride All
    9. Order allow,deny
    10. allow from all
    11. </Directory>
    12.  
    13. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    14. <Directory "/usr/lib/cgi-bin">
    15. AllowOverride None
    16. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    17. Order allow,deny
    18. Allow from all
    19. </Directory>
    20.  
    21. ErrorLog ${APACHE&#95;LOG&#95;DIR}/error.log
    22.  
    23. # Possible values include: debug, info, notice, warn, error, crit,
    24. # alert, emerg.
    25. LogLevel warn
    26.  
    27. CustomLog ${APACHE&#95;LOG&#95;DIR}/access.log combined
    28.  
    29. Alias /doc/ "/usr/share/doc/"
    30. <Directory "/usr/share/doc/">
    31. Options Indexes MultiViews FollowSymLinks
    32. AllowOverride None
    33. Order deny,allow
    34. Deny from all
    35. Allow from 127.0.0.0/255.0.0.0 ::1/128
    36. </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
Reset Password
Fill out the form below and reset your password: