How to Setup XAMPP WordPress Virtual Hosts

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 “Windowssystem32driversetc

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:

[inline]
[code]
<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>
[/code]
[/inline]

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.