Join 3,557 readers in helping fund MetaFilter (Hide)


Hosting two websites locally
June 6, 2011 4:36 AM   Subscribe

Hosting more than one website locally - explain to me like I'm stupid.

I am in the process of building a fairly straightforward website on Wordpress. It's nearly finished, but now I have to build another.

I worked out how to host the first site locally to build and test it - I'm using WAMP on Windows 7, and can access the site from my browser by going to localhost. Adding a second independent site has me stumped, and my little brain feels as though the guides I find online are missing steps.

So, could you tell me how I can make a second locally hosted Wordpress website? And (this feels like a hilariously stupid question) how do I access it from my browser? Type in 'localhost2'?

I assume I'll need to make a new database using phpMyAdmin and edit my hosts file, but what happens in between is presently eluding me, including how all this specifically applies to Wordpress. Could you give me a straightforward, preferably step-by-step, explanation of what I should do and (if it's not too much trouble to explain) why? Or direct me to a guide designed for stupid people?
posted by tavegyl to Computers & Internet (9 answers total) 6 users marked this as a favorite
 
You will need to set up multiple virtual hosts, which is easier than it sounds. Here's a tutorial on setting up multiple virtual hosts with WAMP.

As for the database question, you'll need a second database for your second Wordpress installation. You should be able to create one with phpMyAdmin, which I think is bundled with WAMP.
posted by JuliaKM at 4:49 AM on June 6, 2011


If that first tutorial seems too confusing, this one looks a little easier to understand to me.
posted by JuliaKM at 4:51 AM on June 6, 2011


If nobody outside of your local network is ever going to access these sites, then you really don't need to worry about virtual hosts. Just do it like Gator suggests. If you will be allowing access from the Internet, then you need the virtual host setup.
posted by COD at 5:04 AM on June 6, 2011


You're using WAMP? You should have a folder called C:/wamp/www/ then, right, that has a folder containing your site files? With my WAMP setup, I have multiple separate sites listed in that folder, like C:/wamp/www/mysite.com/ where I can just double-click the index page in that folder to bring up the site in my browser, which shows as file:///C:/wamp/www/mysite.com/index.php in the address bar.
posted by Gator at 5:37 AM on June 6, 2011


Thanks for the replies thus far. So, am I correct in my understanding that:

1. I have to create a second Wordpress installation to handle the new website. This means I extract a new set of Wordpress files into c:/wamp/www/NewSite/

2. I create a new database using phpMyAdmin and call it NewSite.

3. I edit the new wp-config file to recognise the database, user name, password and hostname as set in step 2.

4. Optionally, I set up a new virtual host as described by JuliaKM's linked tutorials, using the same hostname as defined in step 2.

Does this make sense?
posted by tavegyl at 5:55 AM on June 6, 2011


Yes, that's pretty much it, tavegyl, I do it all the time on my servers, and have it down to a five-minute process.

I'd move step 4 before step 3 though; if you specify a hostname in the WordPress setup, that has to be a valid, DNS-resolving, webserver-responding URL which your WordPress installation must exist at. If you tell WordPress it's on a different hostname than what it's actually installed on, it won't behave properly, and it's more of a pain to change after the fact.

Also, WordPress can use a single database, with a different 'prefix' for each different WordPress installation. "wp_" is the default prefix, but you can make it something specific to each Wordpress installation, and thus you can have one database and SQL login store the data for numerous WordPress sites. There's a variety of advantages and disadvantages to either way (more hard drive reads with two separate databases vs memory overhead of one large database, scalability of security for numerous websites, etc), but for simplicity, especially if your host has a restriction on the number of databases you can create, it might be useful.
posted by AzraelBrown at 7:00 AM on June 6, 2011


If you will be setting up multiple WP blogs, it's a good idea to look into installing Wordpress Network sooner rather than later. You will only need one database if you do this too.
posted by turkeyphant at 10:28 AM on June 6, 2011


If anyone is still reading this - I thought I'd done it all right, but I'm getting the message 'Error establishing a database connection' when I try to access newsite.localhost

Any suggestions where to look for mistakes would be much appreciated indeed.
posted by tavegyl at 6:26 AM on June 7, 2011


Managed it, phew. If anyone is still reading, I have no idea how I did it. The two tutorials JuliaKM posted give different instructions. This one made more sense in my case, so I used it. Make sure to read the comments as well. I followed the steps I mentioned in my earlier reply, with AzraelBrown's suggested amendment.

It didn't work.

I undid everything, re-did it. Restarted WAMP services many times. Finally re-started the computer. Then realised that I'd made two mistakes:

1. In wp-config, I'd listed the database as 'Newsite'@'newsite.co.uk'. I replaced this with 'newsite'

2. When going to install Wordpress, I'd been typing file:////wamp... instead of http://newsite.co.uk/wp-admin/install. Doh!

It works now, thanks all for the advice.
posted by tavegyl at 4:45 AM on June 9, 2011


« Older I want to get into game develo...   |  Please suggest ways to make th... Newer »
This thread is closed to new comments.