Skip to content

Instantly share code, notes, and snippets.

@BjornW
Last active March 16, 2021 04:54
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save BjornW/6494183 to your computer and use it in GitHub Desktop.
Save BjornW/6494183 to your computer and use it in GitHub Desktop.
A short description of how I've setup a WordPress Multi-Tenant architecture. This is based on the excellent post by Jason McCreary http://jason.pureconcepts.net/2013/04/updated-wordpress-multitenancy/ and the great ascii art explanations by Wes Koop (https://gist.github.com/weskoop/3796570) & Mark Jaquith (https://gist.github.com/markjaquith/622…
I'm using Ubuntu 12.04 and I'm following the Debian/Ubuntu way of dealing with config files. I presume you know how to work with sudo and such
- Install last stable version of WordPress (in my case 3.6) with Subversion into /opt/wordpress/3.6
- create a symlink /opt/wordpress/stable ==> /opt/wordpress/3.6
- create a directory sites in /var/www/sites
- create a directory specific for your site using the domain name e.g. /var/www/sites/example.com
- create a directory wp-content in /var/www/sites/example.com
- create a directory wordpress in /etc
- create a directory named as you site's domain name, e.g. in /etc/wordpress
- copy from /opt/wordpress/stable/wp-config-sample.php to /etc/wordpress/example.com/wp-config.php
- fill in the wp-config.php file as you would normally do with the database credentials and such.
- create a symlink from /var/www/sites/example.com/wp-config.php ==> /etc/wordpress/example.com/wp-config.php
- create a new wp-config.php in /opt/wordpress/ with the following code:
````
<?php
// set global configurations
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content');
// load site-specific configurations
require_once dirname($_SERVER['DOCUMENT_ROOT']) . '/' . $_SERVER['SERVER_NAME'] . '/wp-config.php';
?>
````
NB: Keep in mind that the protocol is now hardcoded to use http:// it would be better to add something like $_SERVER['HTTPS'] to check if we need https or not.
== Updating ==
1) Download or better check out new version from Subversion, for instance version 3.6.1:
svn co http://core.svn.wordpress.org/tags/3.6.1 3.6.1
2) Now you may remove the stable symlink which was pointing to 3.6 and create a new symlink to 3.6.1:
rm stable
ln -s 3.6.1 stable
3) Visit the site, to check if any database updates are needed.
4) Finished!
@BjornW
Copy link
Author

BjornW commented Jan 25, 2014

Do not forget to access the site for the first time with /wp in the url

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