Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve WordPress Multi-site Support #38

Open
evandiamond opened this issue Jul 10, 2017 · 13 comments
Open

Improve WordPress Multi-site Support #38

evandiamond opened this issue Jul 10, 2017 · 13 comments

Comments

@evandiamond
Copy link

evandiamond commented Jul 10, 2017

Bug Report

Tell us about your setup
WordPress Multi-site from Pantheon

What is your lando version and operating system?
lando-v3.0.0-alpha.13 on Running Mac OS Sierra 10.12.5

Have you previously installed lando? If so, what version?
No

Tell us about your bug
I don't think Lando plays well with WordPress Multi-site.

Please detail the steps we can take to replicate this bug. Be as detailed as possible.

  1. Ran `lando init pantheon
  2. Filled in crendentials
  3. lando start
  4. Error:
warn: wordpress_network is not a supported recipe.
error:  TypeError: Cannot read property 'filemount' of undefined
  1. If I change my framework to just "wordpress" instead of "wordpress_network" which was set by default, I can proceed forward.
  2. lando start
  3. No longer a frameworks bug, but I get a:
PHP Fatal error:  Uncaught Pantheon\Terminus\Exceptions\TerminusException: Could not save data to a file because the path /var/www/.terminus/cache/commands cannot be written to. in /var/www/.composer/vendor/pantheon-systems/terminus/src/DataStore/FileStore.php:155
  1. lando restart
  2. Things appear to be normal...
  3. Setup finishes. 2 of the URL's are in red. 4 on in green.
  4. Let's try one of the links: http://localhost:32787 - "Site cannot be reached"
  5. I can remove these two lines in my WordPress wp-config.php file:
define( 'WP_ALLOW_MULTISITE', false );
define('MULTISITE', false);
  1. Head back to: http://localhost:32787 - WordPress wants to start installation.
  2. Successfully imported the database using the Lando documentation
  3. In order to check my multi-sites, I need to turn true the items in Step 12. However when I do so, I get:
Error establishing a database connection

If I can just get this last part working I'll be golden, everything else is working great! @pirog

Feature/Enhancement Request

Would love to see WordPress multi-site support!

@pirog
Copy link
Sponsor Member

pirog commented Aug 17, 2017

@serundeputy
Copy link

I spun up a generic WP site using the wordpress recipe and enabled Multisite per: https://codex.wordpress.org/Create_A_Network

  • enabled mutisite as subdomains

From outside the container (localhost) I get 404s to the subdomains both in browser and curl:

geoff@yep wp-local-mu $ curl -I http://blah.wp-local-mu.lndo.site/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 25 Aug 2017 12:37:10 GMT
Content-Length: 19

From inside the appserver container 200:

www-data@519472ba2809:/app$ curl -I http://blah.wp-local-mu.lndo.site/
HTTP/1.1 200 OK
Date: Fri, 25 Aug 2017 12:36:57 GMT
Server: Apache/2.4.10 (Debian)
X-Powered-By: PHP/7.1.7
Link: <http://blah.wp-local-mu.lndo.site/wp-json/>; rel="https://api.w.org/"
Content-Type: text/html; charset=UTF-8

From database container 200:

root@776716edbd8f:/app# curl -I http://blah.wp-local-mu.lndo.site/
HTTP/1.1 200 OK
Date: Fri, 25 Aug 2017 12:46:43 GMT
Server: Apache/2.4.10 (Debian)
X-Powered-By: PHP/7.1.7
Link: <http://blah.wp-local-mu.lndo.site/wp-json/>; rel="https://api.w.org/"
Content-Type: text/html; charset=UTF-8

This made me think adding subdomain routes to the appserver might work a la: https://docs.lndo.io/config/proxy.html, but so far I've not been able to get that to work in a wordpress recipe.

@pirog
Copy link
Sponsor Member

pirog commented Aug 25, 2017

@serundeputy maybe we can take a look at this together sometime soon. It looks like things might be easier to get rolling than i had previously thought. 🤞

@evandiamond
Copy link
Author

evandiamond commented Aug 26, 2017 via email

@davisshaver
Copy link

I'm starting to use Lando for managing multisite of Pantheon WordPress. I pulled the db and files and ran into an issue that's on Trac here https://core.trac.wordpress.org/ticket/41424 also been raised in pantheon-systems/documentation#2982.

In my case I was able to use the existing wp search-replace command plus the following to get multisite loading in Lando environment: lando wp search-replace "domain.com" "domain.lndo.site" wp_blogs --url=domain.com

@dustinleblanc dustinleblanc changed the title WordPress Multi-site Support Improve WordPress Multi-site Support Feb 22, 2018
@nullvariable
Copy link

nullvariable commented Feb 26, 2018

I was able to get basic multi-site working with the stock WordPress recipe fairly easily. I think existing sites and more complex domain setups may take more work, but here's the steps I took.

lando init --recipe=wordpress

Add some extra domains to the proxy section

proxy:
  appserver:
    - siteone.lndo.site
    - two.siteone.lndo.site
    - three.siteone.lndo.site

Add settings to wp-config.php

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'siteone.lndo.site');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Update the .htaccess file per WordPress network install instructions:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

Then I had to run lando rebuild -y for it to pick up the .htaccess changes it seemed.

I believe the only part that is likely to get sticky for others is the multi-domain stuff. Nginx support would take more work since a custom config would be needed instead of .htaccess overrides. Doing the search-replace sort of work and stuff from existing sites is a real pain, but not really something that has to do with Lando, more of a WP thing.

Happy to do more tests and offer more advice, but I think documentation is probably all that's needed here, unless we want to work on custom nginx configs or a more automated setup of some sort.

@nylen
Copy link

nylen commented Oct 1, 2018

Doing the search-replace sort of work and stuff from existing sites is a real pain, but not really something that has to do with Lando, more of a WP thing.

I think it should be possible to do this more automatically with fewer (or no) DB changes, by overriding the WP logic to pick a site based on the incoming URL.

Edit: This ended up being more trouble than it was worth. Do not recommend.

I gave it a shot here: ClassicPress/ClassicPress-Network#5

It is pretty specific to our setup (every site is a subdomain, with www. as primary), but it seems to work. Something a bit more general could be interesting too.

@stale
Copy link

stale bot commented Jan 31, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@digisavvy
Copy link

Is there a document for WordPress on how to setup lando and WP for multisite? I'm trying to configure a sub-folder install and struggling.

@digisavvy
Copy link

@pirog ^^

@pirog
Copy link
Sponsor Member

pirog commented Aug 2, 2022

@digisavvy not that im aware of. this is something we plan to first-class support in Lando 4 but that is still months out.

that said, it's highly likely someone in the lando Slack has got a recipe or guide etc. If they do it would be slick to add it as a guide in our wordpress docs: https://github.com/lando/wordpress/tree/main/docs

@robclancy
Copy link

Why is this issue closed if Lando 4 is meant to be helping with it and not out yet?

@pirog
Copy link
Sponsor Member

pirog commented May 16, 2023

@robclancy not sure but reopening and moving to https://github.com/lando/wordpress

@pirog pirog reopened this May 16, 2023
@pirog pirog transferred this issue from lando/lando May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants