Local (2.4.5), Bedrock and Multisite


#1

Hey there,

Recently I had to reinstall the current local install of the multisite and can’t make it work. I hope you can help me with that.

One of the steps for the install that we are getting stuck on is replacing the code in conf/nginx/site.conf with the following code:

server {
server_name  _;
 return 302 $scheme://sitename.local$request_uri;
}

server {
server_name ~^(.*)\.sitename\.local$ sitename.local;
root /app/public/;

index index.php index.html index.htm;

# special config for Bedrock + Multisite
if (!-e $request_filename) {
  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
  rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
}

include do-not-modify/*.conf;

}

However, after this update, the file starts to download and the file depends on the location you are trying to reach, for instance, if it’s /wp/wp-admin, it downloads admin.php.

I think this is because the latest updates have changed the structure of site.conf file and the code above needs to be updated as well. The current code used to work with earlier versions.


#2

Any update here? Does anyone know anything about it?


#3

Hi @Vladimir,

What version of Custom is the site running? You may need to upgrade your site’s Environment.

I was able to get Bedrock + Multisite to play nicely with Custom 1.3.1. Here’s how you can reproduce the steps I went through:

  1. Install Bedrock into the site’s app folder
  2. Add the following above Config::apply(); in app/config/application.php to support multisite
/* Multisite */
Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', false); // Set to true if using subdomains
Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
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. Add DOMAIN_CURRENT_SITE to the .env file. It should match your Local site’s domain
  2. Add the multisite rewrite and update the web root in conf/site.conf to /app/web to match the Bedrock folder structure.

Here are the first 16 lines of conf/site.conf for my test site:

server {
    root /app/web/;

    # special config for Bedrock + Multisite
    if (!-e $request_filename) {
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
      rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
      rewrite ^(/[^/]+)?(/.*\.php) /wp$2 last;
    }

    index index.php index.html index.htm;

    #
    # Generic restrictions for things like PHP files in uploads
    #
	include includes/restrictions.conf;
  1. Restart the Local site so the config takes effect

Caveats of this setup:

  1. Local will not be able to read the WordPress version nor the database settings under the Database tab
  2. Adminer button under Database tab will not work since it’s expecting app/public to be the webroot

#4

Hey @clay, thanks for your help a lot. Finally found some time to check this solution after the holidays. I can’t share the project information, so the domain name would be website.com, the other site is subdomain.website.com.

My Custom is the following:


The multisite there is always set to “No” after I do changes to application.php and multisite rewrite.

This is the .env file:

The application.php is the following:
%2009%2014-02-53
We use WP_HOME and it should be the same as DOMAIN_CURRENT_SITE as you have put in your code. I tried to add PATH_CURRENT_SITE, which in our case is WP_SITEURL, as: define('PATH_CURRENT_SITE', env('WP_SITEURL') ?: '/'); and it creates weird url then:


If I keep it define('PATH_CURRENT_SITE', '/'); the second pard of weird url disappears.

And this is a part of the site.config file:
%2009%2014-11-38
The same as you have mentioned.

My issue at the moment that the link has this additional https:// in the url when I go to My sites > Network Admin > Sites I end up on the page with the error and this link.

Everything inside of the dashboard seems to be working fine.

I think that there’s something wrong with the rewrite, that’s why it works weirdly. Could you help me with that?


#5

@clay ping, could you help with that ^