Skip to content

Instantly share code, notes, and snippets.

@markjaquith
Last active February 21, 2024 23:56
Show Gist options
  • Save markjaquith/6225805 to your computer and use it in GitHub Desktop.
Save markjaquith/6225805 to your computer and use it in GitHub Desktop.
WordPress multi-tenant directory structure sharing core files for opcode awesomeness, fast deployments, and low disk usage. With inspiration from @weskoop. "=>" indicates a symlink.
sites
|__ ms.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ one.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
|__ two.dev
| |__ content
| |__ index.php
| |__ wp => ../../wordpress/stable
| |__ wp-config.php
wordpress
|__ 3.5.2
|__ 3.6
|__ stable => 3.6
|__ wp-config.php
@weskoop
Copy link

weskoop commented Aug 13, 2013

The original: https://gist.github.com/weskoop/3796570, but Mark's new "hack" wp-config.php is much more robust: https://gist.github.com/markjaquith/6214749

@rgsmith1980
Copy link

Very interesting approach for shops that host multiple WordPress installs. I take it this allows for a "stealth" upgrade of WordPress (i.e. not going through the updater for each site). Any input on what should be best practice for "updating" the site once /stable is re-pointed?

@markjaquith
Copy link
Author

@rgsmith1980 — You mean for the DB upgrade routine? Could just have a deploy script that hits each one. Or just wait for them to be hit (this is what I do, currently). WordPress hasn't done a "OMG, you have to run this migration or your site is broken" DB migration in a while.

@ajmorris
Copy link

@markjaquith In the wp-config.php for each site, would you then just add WP_CONTENT_DIR and WP_CONTENT_URL constants to point to the /content folder? I don't want sites to share themes.

@ajmorris
Copy link

@markjaquith - So I have this set in my wp-config.php file, http://d.pr/i/AKxg. $_SERVER['DOCUMENT_ROOT'] = /var/staging/domain.com1, $_SERVER['HTTP_HOST'] is staging.domain.com. That should give me the right URL and content folder, as I have this setup very similar to what you showed here, http://d.pr/i/4OQA. However, when I go to Appearance > Themes, I get nothing from my /content/themes folder. So at this point I think it's a wp-config.php issue I'm running into.

@troychaplin
Copy link

@markjaquith a massive thanks for both this, and your concept around a master wp-config.php file really opened up doors for me to build out a full WordPress Multitenant application that will power hundreds of installations in an easy to maintain setup at work!

We've been running some form of WP in a multitenant application, updated via composer, for a few years now, but there was always something just not right about it. Previous iterations seemed overly complex, and weren't as intuitive. Our current implementation is much more reliable, easily expandable, and much easier to explain to new developers joining our team.

In keeping with the ideology of open source, I've setup this publicly available package for anyone who sees a benefit in running several WP sites without using multisite, and a lot of this was possible from your 2 posts!

Thanks!

@markjaquith
Copy link
Author

@troychaplin79 — Cheers!

@jimmycypherz
Copy link

@troychaplin79 How can I get in touch with you regarding multitenancy work?
Thanks

@troychaplin
Copy link

@troychaplin79 How can I get in touch with you regarding multitenancy work?
Thanks

My contact info is in my git profile

@waqassalman
Copy link

@troychaplin79 How can i setup your wp-multitenant plugin on my cPanel hosted website is their any specific way for that.

@troychaplin
Copy link

troychaplin commented Jul 14, 2021

@troychaplin79 How can i setup your wp-multitenant plugin on my cPanel hosted website is their any specific way for that.

sorry for the late reply @waqassalman, I've been reworking several aspects of my wp-multitenant repo which also includes an improved readme, the recent changes can be found on the develop branch at the moment. To set this up you'll need access and some knowledge of working on your server via SSH.

@foreverlate
Copy link

I really like this concept of wp-multitenant, will this setup works on the existing setup of WordPress installed on docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment