My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
HowItWorks  
Find out what files are modified and/or used
Featured
Updated Oct 23, 2009 by patrickg...@gmail.com

Introduction

virtualhost.sh makes the following changes to /etc/apache2/httpd.conf:

  • It will optionally change the DocumentRoot to point at $DOC_ROOT_PREFIX (defined in the script itself or in ~/.virtualhost.sh.conf). By default this is your ~/Sites folder.
  • It also adds the following lines to the end of /etc/apache2/httpd.conf:
  • NameVirtualHost *:80
    Include /etc/apache2/virtualhosts
  • Lastly, it adds a line in /etc/hosts to point your virtual host name to your local IP. eg.
  • 127.0.0.1	patrickgibson

Each virtual host's configuration file is stored in /etc/apache2/virtualhosts with a filename corresponding to the name of the virtual host.

Moving to a new computer

If you wanted to move everything over to a new computer, you could simply create a tarball:

cd /
sudo tar czvf virtualhosts.tgz /etc/apache2/virtualhosts /etc/apache2/httpd.conf /etc/hosts

Copy this tarball to your new computer. For this example, we'll assume it is placed on your Desktop. To extract it:

cd /
sudo tar xzvf ~/Desktop/virtualhosts.tgz
sudo apachectl restart
sudo dscacheutil -flushcache

The last two lines restart Apache and flush your computer's DNS cache.

Comment by clifton%...@gtempaccount.com, Oct 23, 2009

Just what I needed. Great work! Thanks!


Sign in to add a comment
Powered by Google Project Hosting