Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've set up a Wordpress Multisite on my Local Mac, and also set up an Apache Virtual Host (e.g http://maindomain.dev) to point to the directory. The Multisite used to be a Directory Based install (e.g http://maindomain.dev/subdirectory), but I read that you convert it to a Domain Based install by changing the value of define('SUBDOMAIN_INSTALL', false); to define('SUBDOMAIN_INSTALL', true); and then updating the .htaccess file. I did all of this, and Wordpress appears to work fine. However, when I create a new site and try to access it (e.g http://subdomain.maindomain.dev), the browser (Chrome) just hangs for a while and then times out.

I read somewhere that a Wordpress Multisite domain-based install can't be installed locally, but it should work with an Apache Virtual Host, but I can't remember the URL for that page.

Can anyone help me out?

share|improve this question

migrated from serverfault.com Aug 5 '13 at 17:04

This question came from our site for professional system and network administrators.

    
does subdomain.maindomain.dev resolve to localhost? –  Doon Aug 5 '13 at 12:16
    
No, it just times out and gives Chrome's 'This Webpage is not Available' message: cl.ly/Qds8 –  Tom Oakley Aug 5 '13 at 12:39
    
try adding the subdomains to your /etc/hosts file pointing to 127.0.0.1, or if you have something intercepting .dev domains, set that up to return 127.0.0.1 for the wildcard. By resolve I meant via dns / local lookup. not chrome (trying to see if issue is DNS based, or apache based) –  Doon Aug 5 '13 at 12:42
    
I added subdomain.maindomain.dev 127.0.0.1 to my hosts file and it now resolves to 127.0.0.1, very quickly. What do I do now? –  Tom Oakley Aug 5 '13 at 13:10
    
assuming that your apache virtual hosts listens on 127.0.0.1 and can deal with the hostname it should work. –  Doon Aug 5 '13 at 13:21

1 Answer 1

I got this working, eventually. Steps to get it working:

Add the subdomain.maindomain.dev to your hosts file (on a Mac, it's located at /etc/hosts), next to your 127.0.0.1 localhost maindomain.dev. Your hosts file should look like this:

127.0.0.1 localhost maindomain.dev subdomain.maindomain.dev subdomain2.maindomain.dev

Of course, you can have other entries in your hosts file as well. But this needs to be located somewhere (preferably at the top). Also, putting all your entries for 127.0.0.1 radically speeds up loading time for vhosts.

Next, open httpd-vhosts.conf (located at /etc/apache2/extra) and where your Virtual Host has been defined, add ServerAlias *.maindomain.dev. The Virtual Host declaration should look like this:

<VirtualHost *:80>
    DocumentRoot "/path/to/folder"
    ServerName maindomain.dev
    ServerAlias *.maindomain.dev
</VirtualHost>

restart Apache using apachectl -k restart (you may need to add sudo before this command).

The only problem with this is that each time you create a new Site using Wordpress Multisite, you have to define it in your hosts file.

I hope this helps anyone who has the same or similar problem to me! :)

share|improve this answer
    
you can also look into things like dns proxies on the local machine (things like pow.cx do this) so you don't need to modify the hosts file all the time, but alas hosts files don't support wildcards (*.dev) but editing the host file for testing isn't too horrible –  Doon Aug 5 '13 at 14:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.