So I just spent a long time fiddling around with the configuration of lando recipes, trying to get a multisite installation running correctly for local development. I thought I write it all down here in case someone else is searching for these, as I couldn’t find a post with lots of detail myself.
I’m assuming lando is installed on your local machine, and you are using a bedrock WordPress installation.
Basically what has to be changed compared to a single site setup:
- Add custom nginx vhosts configuration for the lando webserver container
- Add some multisite environment variables
Adding a custom configuration to the nginx webserver
In order for this setup to work properly for wp multisite the webserver needs to map the bedrock specific /wp
app path on different versions.
I found the default vhosts configuration file via https://github.com/lando/cli/blob/main/plugins/lando-recipes/recipes/wordpress/default.conf.tpl
This needs slight modification to work with in a multisite setup.
...
#Add above first location block
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
}
...
I’ve added the block above to the default.conf.tpl
file, which comes from the default nginx WordPress configuration from trellis. Now you can save this and move it to a new folder in the site
directory. I’ve moved it into a new folder called lando-conf
.
In the .lando.yml
file add the following config section
...
config:
php: '7.4'
via: nginx
config:
vhosts: lando-conf/default.conf.tpl
webroot: web
database: mariadb
xdebug: true
...
Note here that you only have to add the second config section, right below via: nginx
This should now load the customized config.
Next, you have to add the following variables to the .env
file
# .env
# FOR LANDO DEVELOPMENT
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=wordpress
DB_HOST=database
WP_ENV=development
WP_HOME=http://example.test
WP_SITEURL=${WP_HOME}/wp
MULTISITE=TRUE
WP_ALLOW_MULTISITE=TRUE
DOMAIN_CURRENT_SITE=example.test
The new ones are MULTISITE
, WP_ALLOW_MULTISITE
and DOMAIN_CURRENT_SITE
.
Now that this is done, you can proceed and create the containers for lando.
- run
lando start
If you check the page now it will show an error that it can’t establish a database connection, it’s because a multisite setup needs additional configuration
Setup the multisite network via wp cli
- run
lando wp core multisite-install --url=example.test --admin_user=admin --admin_password=admin --admin_email=test@example.com --title="test site" --skip-email --skip-config
So this should be it, you should have a working wordpress multisite setup running from lando containers.