Radicle WordPress Multisite local development with lando

Hi Roots,

We’re setting up a WordPress Multisite in the latest Radicle build, but we’re having trouble getting subdirectories (and subdomains) to work.

While we’re able to add multiple sites, the WP files for each subdirectory site can’t be found on the frontend. For example:

GET https://website.lndo.site/subdirectory/wp-includes/css/dashicons.css?ver=6.6.1 net::ERR_ABORTED 404 (Not Found).

Additionally, we can’t access the WordPress subdirectory admin (https://website.lndo.site/subdirectory/wp-admin/), which results in ERR_TOO_MANY_REDIRECTS.

We’ve installed roots/multisite-url-fixer and configured the multisite as follows in radicle/bedrock/application.php:

/**
 * Multisite setup
 */
Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', false);
Config::define('DOMAIN_CURRENT_SITE', 'website.lndo.site');
Config::define('PATH_CURRENT_SITE', '/');
Config::define('SITE_ID_CURRENT_SITE', 1);
Config::define('BLOG_ID_CURRENT_SITE', 1);

Could you provide any guidance or a possible solution?

Looking forward to your insights.

Best regards,
Lex

You’ll need to make more changes to the Lando setup to support multisite

1 Like

Hi Ben,

Thank you for sharing your previous solution on Multisite Bedrock. I followed the steps, but unfortunately, the implementation isn’t working as expected.

Steps Taken

  1. Custom Nginx Configuration
    The URL you provided for the default Nginx config (https://github.com/lando/cli/blob/main/plugins/lando-recipes/recipes/wordpress/default.conf.tpl) is no longer available. Instead, I used the following from GitHub:
    Lando WordPress Default Config.
  2. Adding Rewrite Rules
    I added the following rewrite rules above the first location block in radicle/lando-config/default.conf:
if (!-e $request_filename) {
  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
  rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
}

Here’s the full radicle/lando-config/default.conf for reference:

# WordPress single site rules.
# Designed to be included in any server {} block.
# LANDOWORDPRESSNGINXCONF

# Upstream to abstract backend connection(s) for php
upstream php {
  server fpm:9000;
}

server {
  listen 80 default_server;
  listen 443 ssl;

  server_name localhost;

  ssl_certificate           /certs/cert.crt;
  ssl_certificate_key       /certs/cert.key;
  ssl_verify_client         off;

  ssl_session_cache    shared:SSL:1m;
  ssl_session_timeout  5m;

  ssl_ciphers  HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers  on;

  port_in_redirect off;
  client_max_body_size 100M;

  ## Your only path reference.
  root "{{LANDO_WEBROOT}}";

  ## This should be in your http block; if it is, it's not needed here.
  index index.php;

  if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;
  }

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location / {
    # Serve static files directly, fallback to index.php with query string support.
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    # Ensure proper handling of PHP files
    try_files $uri =404;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_pass php;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
  }

  location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
  }
}
  1. Adding Nginx Configuration to Lando
    I added the Nginx configuration to .lando.yml:
name: website
recipe: wordpress
env_file:
  - .env.example
  - .lando.env
excludes:
  - vendor
  - node_modules
config:
  php: "8.2"
  via: nginx
  database: mariadb
  cache: redis
  xdebug: true
  webroot: public
services:
  appserver:
    myservice:
      type: nginx
      config:
        vhosts: lando-config/default.conf
        ...
  1. Rebuilding Lando
    I ran lando rebuild -y followed by lando flush.

  2. Issue: Subdirectory Not Loading Properly

  • When trying to access a subdirectory site, the frontend cannot locate the WordPress files. Example error:
GET https://website.lndo.site/subdirectory/wp-includes/css/dashicons.css?ver=6.6.1 net::ERR_ABORTED 404 (Not Found)
  • Additionally, accessing the WordPress admin for the subdirectory (https://website.lndo.site/subdirectory/wp-admin/) results in ERR_TOO_MANY_REDIRECTS.

It seems I might be missing something in the setup. Do you have any suggestions on how to resolve these issues?

Looking forward to your insights.

Best regards,
Lex

Hey Lex,

did you finally make any progress with the Multisite/Radicle/Lando setup?
I failed at a very similar point ultimately with the ERR_TOO_MANY_REDIRECTS error.

We ended up developing locally on a Lando based single site which then deploys into a Multisite. Not pretty at all.
The day will come, when we’ll have to test actual Multisite features locally.

Best regards,
Pawel

PS:
My next idea was building a custom WordPres Multisite recipe for Lando instead of fixing, what appears to not be fixable.

However at the moment I have no clue how to create custom recipes.

Pawel, take a look at this article I wrote about working with Multisite for Bedrock and Lando. I’m not sure if something specific to Radicle might cause issues, but with a stock Bedrock install you can tweak the application.php file to get the current domain from the server environment variables. You can also set up multiple domains in Lando by updating your recipe and adding all domains under a proxy > appserver configuration. This works as long as you have a finite number of subdomains where you can manually add them in the Lando file.

1 Like

I managed to fix it with a workaround.

  1. I used a forked version of the mutlisite-url-fixer from GitHub - noticiesinfo/multisite-url-fixer: Fixes WordPress issues with home and site URL on multisite when using Bedrock and added it to the /mu-plugins.
  2. I grabbed the default lando WordPress default.conf.tpl and added the following multisite nginx configuration above the first location.
# Multisite support
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
}
  1. I added the file default.conf.tpl inside the project to .radicle-setup/lando/default.conf.tpl.
  2. In the .lando.yml I added the .radicle-setup/lando/default.conf.tpl to the vhosts.
name: radicle
recipe: wordpress
config:
  php: "8.3"
  via: nginx
  config:
    vhosts: ".radicle-setup/lando/default.conf.tpl"
  1. In ./bedrock/environments/application.php I added the following config defines.
/**
 * Multisite initialization
 */
Config::define('WP_ALLOW_MULTISITE', env('WP_ALLOW_MULTISITE') ?? false);

/**
 * Multisite configuration
 *
 * After enabling the multisite support, you can enable these options.
 */
if (Config::get('WP_ALLOW_MULTISITE')) {
    $domain = parse_url(Config::get('WP_HOME'), PHP_URL_HOST);
    Config::define('MULTISITE', env('MULTISITE') ?? false);
    Config::define('SUBDOMAIN_INSTALL', env('SUBDOMAIN_INSTALL') ?? false);
    Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE') ?: $domain);
    Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
    Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
    Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);
}
  1. In the .lando.env I added the following.
# Multisite initialization
WP_ALLOW_MULTISITE=false

# Multisite configuration
MULTISITE=false
SUBDOMAIN_INSTALL=false
DOMAIN_CURRENT_SITE='radicle.lndo.site'
PATH_CURRENT_SITE='/'
SITE_ID_CURRENT_SITE=1
BLOG_ID_CURRENT_SITE=1
  1. In the .example.env I added the following.
# Multisite initialization
WP_ALLOW_MULTISITE=false

# Multisite configuration
MULTISITE=false
SUBDOMAIN_INSTALL=false
DOMAIN_CURRENT_SITE='example.com'
PATH_CURRENT_SITE='/'
SITE_ID_CURRENT_SITE=1
BLOG_ID_CURRENT_SITE=1
  1. I added the following to the README.md as instructions.
1. Setup a WordPress site following the lando setup for [local development](#local-development).
2. In `.lando.yml` uncomment `# config:` in the config root node.
3. In `.lando.yml` uncomment `# vhosts: ".radicle-setup/lando/default.conf.tpl"` in the config# node.
4. In the `.lando.env` set `WP_ALLOW_MULTISITE=true`.
5. Rebuild your app with `lando rebuild -y`.
6. Open `WordPress Dashboard > Tools > Network Setup` and setup your network for a subdirectory install.
7. Copy the network configuration rules and assign them to each environment variable in the `.lando.env`.
8. Rebuild your app with `lando rebuild -y`.
9. Your Multisite is now up and running. You can add new sites in the WordPress dashboard.

After following configuration and the README it should work. If not then check another forked version of multisite-url-fixer instead.

Hope this helps!

Greetings,
Lex

PS: Still wish this was integrated in Radicle by default for WordPress. Would be much easier.

3 Likes

Thank you!

:+1: Made a feature request here: https://github.com/roots/radicle/issues/234

Thats awesome!

I forgot to mention the instruction to also add the multisite env variables to the .example.env for deployment. I edited my post and provided information in step 7.

1 Like