(or How to Migrate WordPress Multisite, Maybe)
These are my notes from the first working clone attempt, after less systematic failed/bailed attempts. I.e., this is not tested — be careful!
- Your child sites are in subfolders. You are not using subdomains.
- I happened to have multisite installed already (it was an old version of the site). The nice thing about setting up multisite first is that you’ll know for sure the .htaccess file works & MAMP is set up right. If you don’t have multisite installed, you can probably just copy the WP files over. (Please leave a comment if it works!)
- You are using free, non-pro MAMP (although, you can still use follow these steps, just tweak the first step).
- You are in a mental space where you can follow boring instructions. (It took longer to write this out than it did to copy the site.)
Just 3 steps! With substeps!
This is pretty much like migrating a regular WP site, except updating the db is a pain because the url information is stored in 4 tables + 1 options table for every child site.
Also, the url is sometimes the full url, sometimes just the domain, sometimes the path.
So to make things a little easier, we’re going to set up a virtualhost & use a PHP script to generate a SQL query to do the search & replace.
1. Set up a virtualhost (optional)
My usual local url is structured like:
http://localhost/localprojectThe production site is like this:
http://productionproject.comSo I want my local url to look like:
(Another option is to skip this & change your the server document root settings in MAMP. I also hear that MAMP Pro can set up virtual hosts for you easily. Or maybe you’re using Vagrant and you already know how to do this.)
- Edit 3 hidden files, as outlined in these 14 steps (it’s not that bad really):
- For the hosts file, include www.localproject.dev as well as localproject.dev
- For the httpd-vhosts.conf file, make sure to include a ServerAlias for www.localproject.dev
- Restart Mamp
- Go to
http://localproject.devand make sure it’s working
- Troubleshooting: flush your dns cache or try http://localhost/localproject (this works for me and rewrites to localproject.dev).
2. Import the database and clean it up
Note: Right now this just cleans up WP-generated links & the dashboards. This will not fix media links or internal links. (To fix those, use Database Search and Replace Script in PHP)
- Export the production db.
- Create a new local db & import the production db.
- Download this php script and update the variables.
- Run it (i.e., put it in your Sites folder and open it in your browser), check the sql query output, and copy it.
- In phpMyAdmin, click on the SQL tab. Paste the query. Press ‘go’.
- It might say “1 record updated” or even “0 records updated”. That’s hopefully not true.
- Double-check a few tables to make sure it worked: wp_site, wp_sitemeta, wp_options, wp_blogs, wp_site#_options…
3. Update WP files
You’ve already set up a multisite installation right? And copied over all files in wp-content?
- If you have got multisite set up locally, copy all the files in wp-content. If you don’t have multisite set up yet, copy over all the files in your installation.
- .htaccess file: update
- wp-config.php file
- Point to the new db (just update the name & user, if needed, hostname can stay the same)
- Update the multisite section:
Did it work?
You should be able to log in to your new local multisite. Try going to the dashboard of some child sites.
Please leave me a comment if this worked for you! Or if anything didn’t work. Or if the instructions need fixing. Thanks!