Before you start, check out the Upsun demo app
and the main Getting started guide.
These resources provide all the core concepts and common commands you need to know before using the following materials.
Assumptions
There are many ways you can set up a WordPress Multisite or Upsun project. The instructions on this page are based on the following assumptions:- You selected PHP as your runtime, and MariaDB as a service during the Getting Started guide. It’s also assumed
that while using the Getting Started guide you named the project
myapp, which you will notice is the top-level key in all configuration below. - Your database relationship name is
mariadb(the default) - You have a working WordPress site based on either the WordPress Composer, Bedrock, or WordPress Vanilla guides.
- WordPress is installed in the web/public root of the site and not in a subdirectory of its own (or in the default of
wpif you set up a Bedrock-based site) - You know if you are creating a subdirectory-based multisite or a sub/multi-domain based multisite.
1. Add rewrite rules to your root location
If you are setting up a subdirectory-based multisite, or you followed the Bedrock guide, the following rewrite rules are required. If you followed the Composer based or Vanilla guides and are unsure, or if you think you might convert to a subdirectory-based multisite later, you can add these rules to a sub/multi-domain multisite without any negative effects. Locate theweb:locations section in your .upsun/config.yaml file and update the rules section for your root (/)
location as follows:
If you followed the Bedrock guide and decided to change the default name of the directory where WordPress is installed
(
wp), then you will need to update both the rules and passthru keys accordingly.2. Update the database during the deploy hook
The domain(s) of your multisite are stored in the database itself. This creates a challenge in a system like Upsun where you often create preview environments dynamically during development. To ensure the database for your preview environments is updated with the correct domains, we have created a wp-cli package to automate the process of updating the database with the preview environment’s unique domain name. To install the wp-cli package, locate thebuild: section and update it as follows:
.upsun/config.yaml
If you created your site based on the WordPress Vanilla guide, only add the lines above that start with
wp package
(i.e. skip the composer install line).deploy section and update it as follows:
.upsun/config.yaml
3. wp-config.php / config/application.php
Once our multisite has been set up, we need to expose additional pieces of information inside our wp-config.php (or
./config/application.php for Bedrock) file. In your wp-config.php/application.php file, right above the section
outlined below:
SUBDOMAIN_INSTALL should be set to true if your multisite is a sub/multi-domain site, or false if you will be
setting up a subdirectory-based multisite. Note that MULTISITE is currently set to false; we will update this once
the database has finished being set up for the multisite.
4. Commit and push
You can now commit all the changes made above.upsun/config.yaml and push to Upsun.
Terminal
5. Network (Multisite) Setup
Addingdefine('WP_ALLOW_MULTISITE', true); will enable the Network Setup item in your Tools menu. Use that
menu item to go to the Create a Network of WordPress Sites screen. Follow the instructions on this screen and click
the Install button. You can ignore the instructions on the resulting screen.
Alternatively, you can access a terminal session in the app container (
upsun ssh), and use
wp core multisite-convert to install the multisite.6. Final change to wp-config.php / application.php
Return to your wp-config.php / application.php file and change
Terminal