So while I was redesigning my site, I needed somewhere to develop the new design. I didn’t want to have to setup a sub-domain on the live site because that would be a pain to have to FTP files up everytime I changed something. So I installed XAMPP on my computer.

Basically, XAMPP is a all in one Apache web server. It installs Apache, PHP, MySQL…everything I needed.

Once you install it, you get a web directory here C:Program Filesxampphtdocs (or whichever directory you install XAMPP to). That’s great, everything works fine when you put things in that directory and browse to localhost. But what about if you want to setup multiple sites? That is where I really had to do some digging.

Setting Up Multiple Sites

I found this really good article that walks you through setting up multiple sites on XAMPP. The article was a little longer than I thought it had to be, so I thought I would clarify some things.

  1. Find this file: C:Program Filesxamppapacheconfextrahttpd-vhosts.conf, and open it in notepad.
  2. Find a line that says something like NameVirtualHost *:80. Remove the # sign that you see in front of it; this turns it from being a comment to code that is actually executed. (This was not in any instructions I could find)
  3. Next, scroll to the bottom, and you can add multiple domains. Here is what mine looks like:

    <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/sites/trevordavis.dev/webpages"
    ServerName localhost.trevordavis.dev
    </VirtualHost>

    <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/sites/trevordavis.redesign/webpages"
    ServerName localhost.trevordavis.redesign
    </VirtualHost> 
  4. Finally, find this file: C:WINDOWSsystem32driversetchosts and open it in notepad. You need to add an entry for each site you setup in the httpd-vhosts.conf file. My file looks like this:

    127.0.0.1 localhost
    127.0.0.1 localhost.trevordavis.dev
    127.0.0.1 localhost.trevordavis.redesign 

That’s It

Once you have done this you can browse to http://localhost.trevordavis.dev and http://localhost.trevordavis.redesign on your computer when you have your web server running. This means that you can view PHP files and execute SQL locally.

It’s great.

Let me know if you have any questions.