0

I have taken a copy of a multisite install to work on it locally. I've noticed that if I set define('MULTISITE', true); in wp-config, I get the standard database connection error. If I disable multisite, the theme loads but there are plugins missing.

Can anyone suggest what I have missed? Possibly relevant is that my local dev environment is using NGINX and the original is on Apache. I don't have anything specific to multisite in my nginx config.

If I set both of the following in wp-config:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);

I get redirected to http://http//local.mydevsite/wp-signup.php?new=local.mysdevsite

I also get redirected there when trying /wp-admin

8
  • You say that you have taken a copy - can i assume that you updated the datebase connection constantes within wp-config.php so that the site is not still looking for the original database?
    – David Gard
    Feb 5, 2015 at 10:14
  • Yes,these have been changed to my local copy of the DB and confirmed as correct
    – codecowboy
    Feb 5, 2015 at 10:18
  • Do you still have the define('WP_ALLOW_MULTISITE', true); line in wp-config.php (above the lines in your question)?
    – David Gard
    Feb 5, 2015 at 10:21
  • I've tried with and without that commented. My understanding is that you don't need that line once multisite has been enabled for the first time.
    – codecowboy
    Feb 5, 2015 at 10:22
  • You don't, I think it just adds the 'Networking' option to the Tools menu, but worth looking at. I assume also that you've changed the DOMAIN_CURRENT_SITE constant to reflect the URI of your off-line copy (do not include http:// or a trailing slash)?
    – David Gard
    Feb 5, 2015 at 10:26

1 Answer 1

0

This sounds like an error with the URLs that are defined in the multisite DB and/or a .htaccess issue.

When changing a regular WP install from live to local for example, you can change the URLs by setting this in your wp-config:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

However with multisite there are additional references to the URLs the multisite was set up on in the database. If on your local database you look in the tables wp_blogs, wp_site and wp_options there'll be entrys for the live site in the database. You need to change these to your new local url. i.e. from livesite.com to localsite.com

  • In wp_blogs these are all the entries in the domain column
  • In wp_site this is the entry under the domain column
  • In wp_options this is the option_value corresponding to the option_name of siteurl and home

Alternatively for ease of setup and to minimise any changes to the database I would recommend that you keep the existing urls and just add a rule in your hosts file to root back to your local machine i.e. in your hosts have livesite.com root back to 127.0.0.1 that way your database doesn't have to change. The downside to this is that you'll have to remove the entry to view the live site and some people can find that confusing. So this is completely your choice.

You then need to ensure that your .htaccess has the correct setup for multisite and rewrites. Those settings can be found here depending on if you have a sub domain setup or a sub folder setup.

Finally you need to make sure that on your local setup you have the rewrite_module active and your headers_module active (or equivilent) on your local web server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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