Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Created August 15, 2019 09:06
Show Gist options
  • Save dotherightthing/bf0ff235199fcd9d3d13f3055b295308 to your computer and use it in GitHub Desktop.
Save dotherightthing/bf0ff235199fcd9d3d13f3055b295308 to your computer and use it in GitHub Desktop.
[Migrating to multisite] The steps required to perform a migration. #wordpress

Migrating to multisite

Created: 2017.04.15

wp-config.php

Add this block, replacing NETWORK_DOMAIN.FOO:

define( 'WP_ALLOW_MULTISITE', true );

/* That's all, stop editing! Happy blogging. */

WP Admin > Tools > Network Setup > .. > Install

Choose the option to use sub-domains for your site addresses.

Ignore the warning that Wildcard DNS may not be configured correctly! – the DNS is correct.

You'll be asked to paste some more code to achieve this:

define( 'WP_ALLOW_MULTISITE', true );

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'NETWORK_DOMAIN.FOO');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

/* That's all, stop editing! Happy blogging. */

.htaccess

and this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>

# END WordPress

Add sites

My Sites > Network Admin > Sites > Add New

Add Virtual Hosts

Each host should point to the same network site folder

MAMP PRO > Hosts

Copy over themes and plugins

These are installed into the regular location, but in network parent

Copy over uploads

These are installed into the regular location, but into the SITE_ID subfolder. You can get the SITE_ID by viewing the URL parameter after doing:

My Sites > Network Admin > Sites > Edit

Migrate the old site database

From Moving WordPress: Moving a Site Into a Multisite Network

Export the data

  1. Open up phpMyAdmin or SequelPro
  2. Browse to the orphan's database
  3. Structure
  4. Export everything except the two users tables (wp_usermeta and wp_users)
  5. Save to an .sql file

Make the data ready for the multisite environment

  1. Open the .sql file
  2. Replace domain.foo with domain.NETWORK_DOMAIN.foo
  3. Replace `wp_ with the prefix [$table_prefix][SITE_ID]_ (the $table_prefix is set in wp-config.php)
  4. Save

Dump redundant new-site data

  1. Open up phpMyAdmin or SequelPro
  2. Browse to the network database
  3. Structure
  4. Select all tables with the prefix [$table_prefix][SITE_ID]_ (the $table_prefix is set in wp-config.php)
  5. With selected > Drop

Import the orphan's data

  1. Open up phpMyAdmin or SequelPro
  2. Browse to the network database
  3. Import the .sql file

Users

Users have to be manually recreated in WordPress and then assigned to any existing posts, pages and custom posts.

TODO...

Where do Google Search Console verification files (eg google72281f176e3b2a1f.html) go if there is only one root?

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment