Posted: July 6th, 2010    By: Devin Walker   

I like to develop in a localized environment where I have to do minimal setup and configuration on the remote server when it's time to go live. Working with WordPress makes it very easy to do this and it's a breeze to setup with virtual hosts and the free XAMPP stack.

Why do this? It makes it very easy to move over the WordPress database when it's time to go live. Developing locally is always in your best interest. This method is preferred over 'going commando' because you can keep better control over your code and it's faster to develop. Plus a whole slew of other reasons that you can Google if you feel like it. Let's get started on setting up your WordPress install to use XAMPP's virtual hosting capabilities.

1. Open your Windows Hosts file by clicking on My Computer and navigating to "\Windows\system32\drivers\etc\"

Windows Virtual Host Directory

2. Add the following to the bottom of the hosts file by using your text editor of choice. Notepad will work just fine.

127.0.0.1 somesite.com
127.0.0.1 www.somesite.com

Note: Be sure to replace "somesite" with your actual WordPress website domain name

3. Now navigate to your XAMPP httpd-vhosts.conf by navigating to: C:/XAMPP/apache/conf/extras


4. Uncomment the following line:

NameVirtualHost *:80 Uncomment the following line in your XAMPP Virtual Hosts File

5.Add the following at the bottom of the file and save the file before you close it:

<VirtualHost *:80>
DocumentRoot “E:/xampp/htdocs/”
ServerName localhost
ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “E:/xampp/htdocs/somesite”
ServerName www.somesite.com
ServerAlias www.somesite.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “E:/xampp/htdocs/somesite”
ServerName somesite.com
ServerAlias somesite.com
</VirtualHost>

Wait! One last thing... Now restart Apache and MySQL (using XAMMP) and you should be good to go when you navigate your browser to the url you specified for your WordPress installation using the tutorial above (once you restart the services). If you have any comments or questions be sure to use the comment box below or the Contact DLOCC.

Related posts:

  1. WordPress List Subpages Even if On Subpage I'm building a new site and the navigation on it requires me to use a different bit of code for parent and child pages. I thought I'd share the code for those out there building a similar navigation. Here's a handy bit of code that you can use to display all subpages on a subpage. [...]...
  2. WordPress: If URL is Homepage then do this… Question: In WordPress how to I make sure the page loaded is the homepage URL and display some data if the standard WordPress Conditional Tags are not working for my theme?! Answer: Here's a quick snippet of code that will give you an option to do something if these WordPress basic conditional tags are not [...]...
  3. GoDaddy WordPress Sites Infected by HolasionWeb Malicious Code Have you gotten calls from your clients hosted on GoDaddy about their WordPress site's being 'hacked'? Or perhaps this happened to you yourself. It seems there's a new report of thousands of WordPress sites being infected by malicious javascript inserted on their WordPress website. It's not everyday that WordPress gets 'hacked' by something/one.  Today one [...]...
  4. WordPress Lavalamp Navigation Tutorial Lavalamp is an awesome jQuery plug-in that makes really cool effects for WordPress-based menus and navigation links, and as a bonus it is very lightweight. It can be a bit tricky to implement in WordPress, but after you read this tutorial hopefully you'll be implementing it with ease. Follow along and let's get your site's [...]...
  5. WordPress Fix: Attribute “role” is not a valid attribute I like to design websites that are W3C Compliant.  Your WordPress theme may require some tweaking to be valid.  One error I kept receiving was: Attribute "role" is not a valid attribute. Did you mean "frameborder" or "scrolling"?  I will show you how to correct this error.  Simply put, to correct the error we are [...]...
  • http://www.jonathlee.com Jonath Lee

    Nice guide,

    May I know if the wordpress installation folder needed to be renamed as “somesite.com” as well? or just “somesite”?

    like:
    D:\xampp\htdocs\somesite.com
    or
    D:\xampp\htdocs\somesite\

  • http:/www.dlocc.com Devin Walker

    Either or, doesn’t matter

  • http://www.jonathlee.com Jonath Lee

    Thank you. It works smoothly.

  • Alan-john40

    This artcle s interesting too.I have been looking for such articles and I found the other website article interesting and the techyv.com article is also interesting just though of sharing for all.
    URL is http://www.techyv.com/article/what-xampp

  • Pip

    I followed your instructions but now I have a problem. My links to javascript are  not working now.
    The reason I switched to a virtual server was so my links could easily work.

    In my htdocs folder I had my wordpress site inside a folder called ‘bhs’
    I made bhs my server root

    so if I type localhost (my site comes up without css and javascript)
    because the path used to be
    <script src="/assets/js/libs/modernizr-1.7.min.js”>

    but the template URL is now pointing to 
    http://localhost/bhs/wp-content/themes/bhs/assets/js/libs/modernizr-1.7.min.jsbut that won’t work because localhost is already pointing to the bhs folder inside htdocsso this path then becomes localhost/bhs/bhs/… etcI hope this makes sense to someone because it is making me pull my hair out. I guess I’ll just go back to a non virtual server