The Power of Virtual Hosts (PC)

If you are testing a site locally on your PC, you probably have used XAMPP. XAMPP, by default is installed in the C drive and your server folder by default is C:/xampp/htdocs. As you build lots of sites, that htdocs folder gets filled with more and more folders.

Watch the screencast here!

This is a topic that I have wasted dozens of hours on over the years. It is a very geeky area and most articles online never break it down enough for the common man (or woman) to grasp. They really need to break it down to the core level for someone like me to understand.

At one point you may ask, can you move the server folder?
And the answer is yes you can.

Now, why the heck would you do some as crazy as this?
Well, the power to move your server to any folder is pretty cool but let me give you a practical example. (The entire process of moving a local WordPress site to remote is defined via several screencasts right here) You are developing a wordpress site. Well, all of your links are going to begin with http://localhost and you’ll have to export your wordpress database and do a find and replace with your .sql file to replace all occurances of http://localhost/ with http://your-real-domain/ and then import that new .sql file into your live server’s MySQL (usually via the cpaneland phpMyAdmin). Well, if you change the server folder, you can skip all those steps and save yourself time.

If that sounds cool, read this fantastic article. Summarizing the article you’ll have two make changes inside two Windows files. The only thing I would add to make this article better is that changing the ‘host‘ file on windows is sometimes problematic. The solution to this problem (which is a lame permissions issue) is to save your changes of the ‘host‘ file into your ‘My Documents‘ folder. It will add a .txt to your file and will look like this ‘host.txt‘. Then you copy that file and paste it on top of the existing ‘host‘ file. Somehow this bypasses the permissions issue. There are other ways to accomplish the same thing but I feel the solution I offered is the quickest and least painful.

Oh, and if you want to create a vitual host on Mac OS X… read this article.

Leave a Reply

Your email address will not be published. Required fields are marked *