Local WordPress Multisite Setup
Setting up a local environment for a WordPress Multisite configuration requires additional steps beyond a normal single-site installation.
Set up a Local WP installation, but in the Advanced section check the “Is this a multisite” box.
Once the site is set up, import the database either by using wp-cli tools, Migrate, or the db tool of your choice. The steps for doing this with wp-cli tools are:
Copy the database file into the root of the Local install directory and rename it to “
local.sql
"In Local, click on “
Open in site shell
"In the new Terminal window, type
wp db import
and hitenter
Once the import is complete, change the urls by typing the following (via wp search-replace – WP-CLI Command | Developer.WordPress.org )
wp search-replace --url=example.com example.com example.test 'wp_*options' wp_blogs wp_site --network
Assuming you don’t have an existing Super Admin account, you need to set one up for yourself. Using Local, click the
Database
tab and then clickOpen Adminer
.Open the
wp_users
table and thenSelect Data
Click
New Item
Fill in the relevant information:
You need to know the ID for this new user, so if you use Auto Increment instead of manually putting in an ID you know isn’t already taken, you’ll need to revisit the
wp_users
table again once you're done to see what it was set to.Set the
password
field toMD5
.Set the
user_registered
field tonow
.
Click
Save
.Insert user meta values
Go to the
wp_usermeta
table and click onNew Item
.Fill in the ID of the user you created in the previous step in
user_id
.For
meta_key
enterwp_capabilities
For
meta_value
fill in the field witha:1:{s:13:"administrator";s:1:"1";}
Click
Save
.
You now have an administrator account for the main blog in the multisite, but you need to be a super admin to administer the entire network. Infomation about super admins in a multisite network is stored as site meta in
wp_sitemeta
table. In a single option. Most likely this option already exists. It means that we can use anUPDATE
SQL query and replace the existing super admins with our new one just like this:UPDATE wp_sitemeta SET site_admins='a:1:{i:1;s:8:"kalamuna";}' WHERE site_id=1;
Alternatively you can access thewp_sitemeta
table and edit thesite_admins
field directly, replacing the current content witha:1:{i:1;s:8:"kalamuna";}
Please note that after running this query all the existing super admins will stop being super admins! So maybe in your case it is better to change this option manually. But what is inside it? What is actuallysite_admins
value?It is simple – it is just a serialized array of usernames, for example
Array( 'rudrastyh' )
, orArray( 'misha', 'rudrastyh' )
, so you can useserialize()
PHP function or any kind of a online tool out there to convert it toa:2:{i:0;s:5:"misha";i:1;s:9:"rudrastyh";}
. You you can even format it by yourself:a:2:
– it means an array with 2 elements,i:0;s:5:
– it means the first element of array which is a string of length 5,i:1;s:9:
– second array element which is a string of length 9.
You are now the Super-Admin of the multisite install and should see the usual Network options now when you are in the dashboard.