lando / wordpress

The Official WordPress Lando Plugin
https://docs.lando.dev/wordpress/
GNU General Public License v3.0
13 stars 6 forks source link

Improve WordPress Multi-site Support #38

Open evandiamond opened 7 years ago

evandiamond commented 7 years ago

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
  5. If I change my framework to just "wordpress" instead of "wordpress_network" which was set by default, I can proceed forward.
  6. lando start
  7. 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
  8. lando restart
  9. Things appear to be normal...
  10. Setup finishes. 2 of the URL's are in red. 4 on in green.
  11. Let's try one of the links: http://localhost:32787 - "Site cannot be reached"
  12. I can remove these two lines in my WordPress wp-config.php file:
    define( 'WP_ALLOW_MULTISITE', false );
    define('MULTISITE', false);
  13. Head back to: http://localhost:32787 - WordPress wants to start installation.
  14. Successfully imported the database using the Lando documentation
  15. 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 commented 7 years ago

@serundeputy is going to start some initial work on supporting this.

WordPress Guides: http://mashable.com/2012/07/26/beginner-guide-wordpress-multisite/#OQdBgaxWJqq3 https://premium.wpmudev.org/blog/ultimate-guide-multisite/

Pantheon docs: https://pantheon.io/wordpress/wordpress-multisite

serundeputy commented 7 years ago

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

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 commented 7 years ago

@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 commented 7 years ago

This would be awesome!

On Fri, Aug 25, 2017 at 7:21 PM Mike Pirog notifications@github.com wrote:

@serundeputy https://github.com/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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kalabox/lando/issues/157#issuecomment-325054701, or mute the thread https://github.com/notifications/unsubscribe-auth/AM7eGlellcioEjNGWwgp2ZHyr7NBXz-xks5sb1cGgaJpZM4OTYJc .

--

Evan

davisshaver commented 6 years ago

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 https://github.com/pantheon-systems/documentation/issues/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

nullvariable commented 6 years ago

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 commented 5 years ago

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: https://github.com/ClassicPress/ClassicPress-Network/pull/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[bot] commented 5 years ago

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 commented 2 years ago

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 commented 2 years ago

@pirog ^^

pirog commented 2 years ago

@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 commented 1 year ago

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

pirog commented 1 year ago

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