Multisite on remote server = redirect loop || database error

After successfully provisioning the local development Multisite environment (with Landrush and subdomains and later with subfolders too), I successfully provisioned the remote server and deployed my repo to it, but I did not find a way to deploy in a way that I’d be able to get the remote to work.

Most of the time I get a redirect loop. This redirect loop points to the DOMAIN_CURRENT_SITE plus wp-signup.php?new= and the actual main domain. If I’ve commented out DOMAIN_CURRENT_SITE totally, I was able to get to the signup page, but strangely only sort-of once (I do not get this part to be honest, it loaded once), but then all I was getting is “Error establishing a database connection” message from Wordpress. (I was able to log in to MySQL in the console with the same credentials as in .env.)

Bare Trellis and Bedrock freshly cloned (trying since 10 days, cloned new commits since then as well), only vault.yml; wordpress_sites.yml; application.php for multisite and trellis/hosts files edited. Everything is pushed to the remote repo.

I’ve tried subdomain and subdirectory too, mostly the latter, because of Let’s Encrypt and HSTS it seem more feasible for now (but it’s cool that Let’s Encrypt will support wildcards soon). (Although subdomains with actually hardcoded sites would be the best option for me, but don’t know if that’s possible.)

I have

  • followed the Multisite setup instructions and the rest of the startup guide;
  • checked the similar threads here in Discourse and on the “wide Internets” too, but did not find a solution;
  • rebuilt the DigitalOcean droplet at least 19 times from scratch :smiley: It’s Ubuntu 16.04.3 x64 actually.
  • tried to transform a single site installation the oldschool way following Wordpress.org’s nginx page (At the end I’ve arrived at the Error establishing a database connection page again, one time before I saw a more formal Multisite database problem page.)

Ok, I know thiat I’m a mess or this is a mess at least. :confused: What I’d be really happy to hear if anybody succeeded setting up Multisite lately, and if you can detail the important steps which I might miss, or if I should post some more things, let me know. Thanks in advance!

PS: Single site deployments work flawlessly on remote.

I’m hoping you just need to use wp-cli’s wp core multisite-install as a final step:

# provision using server.yml

# deploy using deploy.yml or bin/deploy.sh

# SSH to server as the web user
$ ssh web@example.com

# Change to site directory
$ cd /srv/www/example.com/current

# Install WP multisite
$ wp core multisite-install --title="Title" --admin_user="username" --admin_password="password" --admin_email="you@domain.com"

If it outputs The network already exists you could (backup data if you need it, then) wp db reset and try the wp core multisite-install again.

Then see if you can connect in the browser.

Let us know of any solution you may find so we can get it in the docs or fix it in the code.

3 Likes

Thank you very much @fullyint, this was the problem, and what you wrote solved it!
(You’ll have beers if I get a chance, just come to Budapest. Thanks, really!)

As I dug deeper, I realized that wp core (multisite-)install happens only on the development environment here, so I think this info and the command you’ve posted would be good to have in the (Multisite) documentation.

So I’ve tried it, built up everything from scratch again, and it worked. (This took me so long.)

(My observation: if you visit your remote multisite:

  • after provision: that’s an error 500;
  • after deployment: that’s a redirect loop;
  • after WP-CLI install: it works.)

Additional remarks:

  • I’ve realized (reading some Discourse threads) that it’s easy to set up subdomains with SSL on Multisite (but only if you know your future site’s URLs) by adding additional canonicals to site_hosts, which will be “letsencrypted” too.
  • After you set your multisite up, your main site will have /wp/ in all the URLs, although interestingly the URLs without /wp/ will work as well. This can be solved with a plugin from felixarntz’s multisite fixes which I found actually here. I know it’s not really a Trellis-specific thing, although it comes from moving WP to the wp directory, and because of this, I’m wondering that this might also be a good part of the Multisite documentation – as a suggestion.
1 Like

@iamkarex Thanks for the update! It’s really good info.

No pressure, but if you’re interested in submitting a pull request to https://github.com/roots/docs that would really helpful, while this is fresh in your mind. This item has been buried on my long list of needed Trellis PRs.

A docs PR could be very minimal notes about the wp-cli install step (when staging/production), the issue of /wp/ in urls (e.g., could just link to bedrock#250), and note that ssl with subdomains requires a third-party wildcard cert or knowing the subdomains ahead of time to pass to letsencrypt (but LE hopefully will have wildcard certs January 2018).

Oh, I’d be honored to contribute, thanks for the call and for the guidelines! Will give it a try!

1 Like