Multisite Deployment Best Practices

When copying between environments the database can be included or excluded. When the database is included, we automatically run a search and replace to update the source primary domain to the destination’s primary domain. This becomes complicated with a multisite, however, especially when subsites have custom domains mapped.

NOTE: This article specifically refers to copying (or “deploying”) a multisite network using the WP Engine tools Copy Environment and Legacy 1-Click Staging.


Gather Information

  1. Is the multisite network subdomain or a subdirectory?
    • If you don’t know which type of multisite you are using, open your wp-config.php file and locate one of the following lines:
      • define(‘SUBDOMAIN_INSTALL’, false); = Subdirectory
      • define(‘SUBDOMAIN_INSTALL’, true); = Subdomain
  2. Are any subsites using mapped domains?
    • You are not using mapped domains if the primary site is tacos.com and your subsites are tacos.com/eat or eat.tacos.com
    • You are using mapped domains if the primary site is tacos.com and your subsites have unrelated domains; eattacos.com, austintacos.org, tacostore.com
    • If you are using the legacy mu-plugin Domain Mapping method, skip to this section.


Copy to STG/DEV for Testing

Subdomain & Subdirectory Multisite

  • Copy Site will work normally because the subdomains/subdirectories are based on the primary domain

Domain-mapped Multisite with less than 5 subsites

  1. Copy the site to the destination.
  2. Search and replace the mapped domains to a subdirectory or subdomain configuration.
    • There are several tools and plugins available to assist with this.
    • As SSL is not supported on WP Engine sub-subdomains (EX: site1.staging.wpestaging.qa), we also recommend updating subsites from https:// to http:// to prevent SSL errors.
  3. Moving forward, only push the file system to the destination.

Domain-mapped Multisite with more than 5 subsites

  1. Copy the site to the destination
  2. Delete a large portion of the subsites, until you have a few subsites that adequately represent the rest of the sites on the network
  3. Moving forward, only copy the file system to your test environment


Copy STG/DEV to PRD

Files can be copied between environments, but it is not best practice to overwrite your production database as part of your development workflow. Therefore it is never recommended to copy your database from a STG/DEV environment to PRD.

If your theme stores options in the database, make changes in PRD while leveraging backup points and Preview options.

Subdomain & Subdirectory Multisite

  • Copy Site will work for the file system
  • Do not copy the database

Multisite with Mapped Domains

  • Copy Site will work for the file system
  • Do not copy the database
  • If database is copied, run a search and replace on the destination site afterwards to update the subsite to the correct custom domain
    • There are several tools and plugins available to assist with a search and replace

Alternatively, develop locally and push file changes to both environments using Git.


Copy Multisite as a “Starter” Template

  1. Convert the destination environment to multisite
  2. Copy Site will work for the file system to the destination site
  3. Do not copy the database to the destination
  4. Continue with a normal workflow to add new subsites to the destination site


Copy Subsite to Another Site

The short answer is this can be done, but it cannot be done with WP Engine’s Copy Site tool.
This is a manual process and could require a developer for less technical users.

  1. Login to the dashboard of the subsite you wish to migrate
  2. Select Tools
  3. Click Export
  4. Select All Content
  5. Click Download Export File
  6. Login to the dashboard of the destination site
    • If you are migrating to another multisite, create a new subsite first
  7. Select Tools
  8. Click Import
  9. Select WordPress
  10. Click Choose File
  11. Select the file exported in Step 5
  12. Click Upload File and Import

These steps will migrate all posts, pages and media used within them. It does not, however migrate the theme or plugins. These will need to either be added again manually or by copying the plugin/theme directories over using SFTP.


Copy Multisite While Using the Domain Mapping mu-plugin

If you have an older site using the legacy Domain Mapping mu-plugin, or another domain mapping plugin is necessary for your site, you can refer to these steps. Please be aware that the legacy Domain Mapping mu-plugin is unsupported by the author at this point and we do not advise using it due to the security and performance implications that may have.

  1. Copy site will work as expected for files
  2. Copying the database to Production is never recommended
  3. If the database is copied to Stage/Dev, then disable the Domain Mapping mu-plugin after copy
  4. This should allow your subsites to load over the subdomain or subdirectory URL assigned by WordPress

Domain mapping plugins (as opposed to native mapping) keep your domain set to the original subdirectory/subdomain URL in the original wp_blogs database table. These plugins then map the custom domain in a separate, custom database table. This setup allows the site to undergo a search and replace during the copy site process as normal. The original wp_blogs table is then used instead of the custom mapping table when the plugin is deactivated.

NOTE: Sites should not use both native mapping and a domain mapping plugin at the same time, as this will cause login and cookie errors.


NEXT STEP: Development Workflow Best Practices

Update Multisite Plugins Automatically

Smart Plugin Manager updates multisite plugins automatically, then tests your pages for errors to ensure those updates don't break the sites in your network.