Migrating WordPress Multisite to a Local Development Environment

This post is primarily a reminder to my future self. However, I don’t think I’m alone in this struggle. Migrating WordPress multisite can be quite a challenge, especially if you’re migrating from a live site to a local development environment. If you’re using http://localhost as your local development environment root with individual sites placed in subfolders like I was doing, your URL structure is most likely quite a bit different than the live site you’re trying to migrate.

Some day I may write a full tutorial on how to accomplish this, but for now I just want to highlight the missing piece that I didn’t find in any other tutorials (and that I spent a few days trying to find).

Problem

I looked through all sorts of documentation and followed many different tutorials, but I kept running into the same errors:

Error establishing a database connection

or:

The page isn't redirecting properly

I finally set up a multisite installation from scratch and compared it to the one I was troubleshooting. At last I found the discrepancy that wasn’t mentioned in any of the documentation or tutorials I had seen.

Solution

In the wp_blogs table, each row has a couple columns that are important when dealing with this issue. Please note the following columns:

  • domain
  • path

On the live site, they looked something like this:

  • domain: example.com
  • path: /

After using search/replace on the database to prepare it for my local dev environment, they looked like this:

  • domain: localhost/example
  • path: /

However, nothing worked until I edited them to look like this:

  • domain: localhost
  • path: /example/

Keep in mind, the wp-config.php settings need to be correct as well, but none of those issues were buried as deep as these troublesome settings in the wp_blogs table.

 

 

 

 

 

 

 

Posted in

Leave a Comment

Your email address will not be published. Required fields are marked *