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

WordPress Multisite SubDirectory #363

Closed
tmort opened this issue Aug 23, 2018 · 13 comments

Comments

@tmort
Copy link

commented Aug 23, 2018

ISSUE TYPE

  • Bug Report

OS / ENVIRONMENT

  1. Host operating system: macOS High Sierra 10.13.6
  2. Native Docker or Docker Toolbox: Native Docker (Mac)
  3. Docker version: Docker version 18.06.0-ce, build 0ffa825
  4. Docker Compose version: docker-compose version 1.22.0, build f46880f
  5. What containers are running: dbox_mysql_1, dbox_httpd_1, dbox_php_1, dbox_bind_1
  6. Container versions: cytopia/mariadb-10.1:latest, devilbox/nginx-stable:0.22, devilbox/php-fpm:7.2-work-0.32, cytopia/bind:0.15

SUMMARY

I'm switching Devilbox over to be my primary development environment (and getting away from MAMP PRO). So far, everything has transitioned perfectly. WordPress and other applications have come over without issue.

WordPress Multisite, however, has thrown a wrench into the system. When creating a brand new WordPress Multisite with subdirectories (e.g., "http://example.com/subdirectoryname/wp-admin/") I am encountering a broken page. More specifically, I'm encountering "Too Many Redirects."

Initially, I assumed this was a WordPress multisite issue and took steps to diagnose WordPress myself. Multisite on Devilbox does work, allowing me to access my main site (http://multisite.loc) as well as the admin and network admin of the multisite (http://multisite.loc/wp-admin/ and http://multisite.loc/wp-admin/network/).

After confirming that Multisite was correctly configured (by setting up the same files on a remote development server), I have determined my NGINX configuration may need to be tweaked to accomplish subdirectory routing.

WordPress suggests this out of the box: https://codex.wordpress.org/Nginx#WordPress_Multisite_Subdirectory_rules

However, I have had no luck converting this CONFIG file into the nginx.yml file that Devilbox requires. I have a working vhost-specific nginx.yml working (/my/path/data/www/multisite/.devilbox/nginx.yml), and I have confirmed this file is working when restarting Devilbox (I can break routing, so it's loading the file correctly.

I'm hoping someone can use the multisite subdirectory rules and point me in the right direction to convert this to the yml file nginx will need.

STEPS TO REPRODUCE

Create a new vhost file

mkdir -p /path/to/data/www/multisite/htdocs

Use wp-cli to download and install a network:

wp core download && wp config create --prompt

Add your database information and then enable multisite:

wp core multisite-install --prompt

Make sure you choose subdirectory and NOT subdomain.

After install, access the network settings page: http://multisite.loc/wp-admin/network/

Create a new site: "http://multisite.loc/testnetworksite/"

Attempt to access http://multisite.loc/testnetworksite/ or http://multisite.loc/testnetworksite/wp-admin/

EXPECTED BEHAVIOUR

Once the network is set up, any subdirectory site should route correctly and allow access to http://multisite.loc/testnetworksite/ or http://multisite.loc/testnetworksite/wp-admin/

ACTUAL BEHAVIOUR

When attempting to access the subdirectory site or it's admin area the "too many redirects" error appears.

OTHER INFORMATION

Devilbox version: Devilbox v0.15 (2018-08-18)
Pulled from Master this morning and rebuilt entire environment.

@cytopia

This comment has been minimized.

Copy link
Owner

commented Aug 23, 2018

Just as a quick shot without much looking yet: https://devilbox.readthedocs.io/en/latest/vhost-gen/example-add-subdomains.html#complex-sub-domains-for-one-project

There was an issue here at Gtihub regarding Wordpress multisite. The above documentation is what was produced to make it work

(issue: #142)

@tmort

This comment has been minimized.

Copy link
Author

commented Aug 23, 2018

@cytopia Thanks for the reply! Looks like that relates to sub-domains and not subdirectories. I'll review and see if there are any clues and follow up if I find anything.

@cytopia

This comment has been minimized.

Copy link
Owner

commented Aug 29, 2018

@tmort did you make any progress on setting up Wordpress with multi sub directories?

@tmort

This comment has been minimized.

Copy link
Author

commented Aug 29, 2018

@cytopia Still working through this but haven't been able to crack it just yet.

@cytopia

This comment has been minimized.

Copy link
Owner

commented Dec 31, 2018

@tmort Can you give me a heads up on the progress. If this has not been cracked yet, let me know the status and I will do some work on this one in order to provide a working example in the tutorials section.

@cytopia cytopia self-assigned this Dec 31, 2018

@tmort

This comment has been minimized.

Copy link
Author

commented Jan 1, 2019

@cytopia Unfortunately no, I have yet to figure this one out. If you could provide a working example that would be amazing!

Thank you for your help and a great product.

@tmort

This comment has been minimized.

Copy link
Author

commented Feb 20, 2019

@cytopia Any update on this? I'm still running into issues where WordPress Multisite with Subdirectories is rendering an issue.

@cytopia

This comment has been minimized.

Copy link
Owner

commented Feb 20, 2019

Not from my side so far. I also haven't used Wordpress for quite some time now. Do you have a good tutorial that explains multi site setup in general for Wordpress?

@tmort

This comment has been minimized.

Copy link
Author

commented Feb 20, 2019

Absolutely:

Setup a WordPress Multisite:
https://codex.wordpress.org/Create_A_Network#Allow_Multisite

WordPress recommended NGINX Rules:
https://codex.wordpress.org/Nginx#WordPress_Multisite_Subdirectory_rules

I'm also around today if we can somehow hop on Discord or Gitter (which would you prefer) you can ask me any WP-related questions.

@tmort

This comment has been minimized.

Copy link
Author

commented Feb 20, 2019

I'm also noticing a very odd thing that's happening while I'm trying to debug this. Here is what I'm seeing happen:

  1. Copy a vhost nginx config from /devilbox/cfg/vhosts-gen/nginx.yml-example-vhost into /www/myproject/.devilbox/nginx.yml
  2. Rename myproject to test. Then rename test to myproject. Check docker-compose logs httpd and see it says it made the switch.
  3. Test the config, nothing happens or the site is broken.
  4. To ensure everything took, I stop Devilbox and start it again.
  5. Now, none of my virtual hosts work. When reviewing the virtual host page, they are all "red" but my hosts file is up to date.
  6. Restarting a few times does not help. I remove the nginx.yml file from /www/myproject/.devilbox/ and then restart. Now the virtual hosts are working again.

Not sure if this helps or leads you to another issue that could be wrong with my setup. Really appreciate the help!

@cytopia

This comment has been minimized.

Copy link
Owner

commented Feb 20, 2019

I'm also noticing a very odd thing that's happening while I'm trying to debug this. Here is what I'm seeing happen:

This is most likely due to a misconfigured nginx.yml. Can you check your docker-compose logs httpd output.

@tmort

This comment has been minimized.

Copy link
Author

commented Feb 20, 2019

The output looks correct, no issues. I am removing all installations and starting clean with only a "multisite" installation so I can debug without any other issues.

I sent a copy of the base WP Multisite install via a PM in Gitter.

WordPress also provides .htaccess settings when building the multisite (https://codex.wordpress.org/htaccess#Multisite) - maybe this could help in composing an example nginx.yml or other config files?

@tmort

This comment has been minimized.

Copy link
Author

commented Mar 1, 2019

Hey there, I went ahead and switched over to the Apache side of things to get this working. Going to go ahead and close this. Appreciate you trying to help and for a great product! If I figure the Nginx portion out I'll be sure to post back here for anyone in the future.

@tmort tmort closed this Mar 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.