Setting up local dev environment

I'm posting this more for future reference in case I need it again, but maybe it will help someone out there.

I've been working on setting up my development environment tonite the way that I want it (and can you believe I even turned the tv off ... :shock: but it will be turned back on in about 20 min so I can watch GH on SoapNet ... I love having that channel ... but I digress ... ). I wanted to set everything up once right and not have to do it again.

Since I'm running locally, I needed to use http://localhost to access my stuff. But what about subdomains? And what about different main domains? For example, I wanted to set up the Avalanche site so I could work on that and a dev version of this site and a dev version of a new site I'm planning. But I didn't want to have to do http://localhost/avalanchecountry or whatever. I wanted to be able to do http://avalanchecountry and get to my local copy.

I did a little searching online and found out how to set up a Virtual Host for my local dev environment. And I already new how to add entries to my HOSTS file. The following is what I needed to do to be able to use http://avalanchecountry to access my local dev version ...

Add the following to the HOSTS file:

CODE:
  1. 127.0.0.1 avalanchecountry

Add the following to the httpd.conf file:

CODE:
  1. NameVirtualHost *
  2. <VirtualHost *:80>
  3.  ServerName localhost
  4.  DocumentRoot "C:/websites/public_html"
  5.  DirectoryIndex index.php index.html index.html index.htm index.shtml
  6. </VirtualHost>
  7.  
  8. <VirtualHost *:80>
  9.  ServerName avalanchecountry
  10.  DocumentRoot "C:/websites/public_html/avalanchecountry"
  11.  DirectoryIndex index.php index.html index.html index.htm index.shtml
  12. </VirtualHost>

And to set up a subdomain, just a little tweak ...

Add the following to the HOSTS file:

CODE:
  1. 127.0.0.1 design.hightechredneckwoman

Add the following to the httpd.conf file:

CODE:
  1. <VirtualHost *:80>
  2.  ServerName design.hightechredneckwoman
  3.  DocumentRoot "C:/websites/public_html/design"
  4.  DirectoryIndex index.php index.html index.html index.htm index.shtml
  5. </VirtualHost>

Then stop and restart Apache. And all is happy happy. Woohoo! Now I can spend the weekend working on my own websites for a change. I haven't done that in WAY too long. It's time to think about ME for a change. :G-razz3:

Comments have been disabled for this entry.