Training

When: Every first Sunday of every month -get a ticket- from $15 (Click Here).

Monday, December 4, 2017

How to Migrate WordPress Multisite - WP Mayor





















How to Migrate WordPress Multisite


Migrating a WordPress Multisite installation can be a tricky
business. It’s not as straightforward as it is with single site
installations, and there are no plugins to help you out.


BackupBuddy
is my preferred plugin for migrating single site installations,
unfortunately it is not yet fully able to perform the same backup and
restore procedure for a multisite installation. What it can do is export
a single site from a multisite installation, which might be useful to
some, but its not really what we are talking about today. Another plugin
you might want to check out is WP Migrate DB Pro which helps you migrate databases from one multisite to another.


In this tutorial, I am assuming that we want to move a site from a
local server to the production server. Here are the basic steps you’ll
need to follow.


Step 1 – Move Database and Files

The first step is to open your FTP client and upload the files from
your computer to the server. Next, on your server set up your database
and user, and use phpMyAdmin to import all the database tables.


If you visit your site now it won’t work, we’ve got some more work
ahead of us before we’ll be greeted by a fully working multisite
installation on our production server.


Step 2 – Modify wp-config.php and .htaccess

Now we need to modify wp-config.php and the .htaccess files to
reflect the new location, database name, user and password. This should
be quite straightforward. Be careful to replace any instance of the old
URL with the new one.


Step 3 – Modify Database Tables

This is the step when most things can go wrong. You need to carefully
modify the database to reflect the new location of your site.


We will be doing lots of search and replace actions, and here is the SQL statement I use for these replacements.


Go to table wp_options

In this table, change the fields
site_url  and 
home.


Go to table wp_blogs

Replace the
domain  and
path  fields with the new values.


Go to table wp_site

Replace the
domain  and
path  fields with the new values.


Go to table wp_sitemeta

Change the
site_url  field


Searching and Replacing within each Subsite

At this point your site should be loading, however we still have
potentially many references to the previous URL in each sub site’s
tables. We need to change those through a search and replace procedure.


There are several possible solutions:


Another popular search and replace script (which takes into account
the serialized nature of data stored in WordPress tables) is the Search and Replace DB script from Interconnectit.


I personally use the Search and Replace plugin and it has always worked fine for me.


Conclusion

That’s it! You should now have a perfect replica of your local multisite installation on your production server.


If you get lost, I’ve found it useful sometimes to set up a new clean
MultiSite installation on the same server, and then compare values and
files between that new installation and the one I’m trying to migrate.
This can help give you a reference that you can use to identify mistakes
you might have done in setting up the migrated website.


We also offer a WordPress Multisite migration service here at WP
Mayor, if you’d prefer to avoid the hassle of doing things yourself.







How to Migrate WordPress Multisite - WP Mayor

No comments: