Single codebase for multiple vhosts

I recently made an attempt to install a single sitewide copy of ownCloud and use it from a couple of vhosts (via nginx) and I got fairly close but there were a few tweaks in core needed to make it really work well enough to deploy for real. I wasn’t keen on maintaining my own patched version of ownCloud, nor dealing with the ownCloud CLA to get something integrated into it’s core, so I dropped the idea. Now with Nextcloud and no CLA involved I am re-enthused enough to have another go at this but first I’d like to know if ANYONE out there would also be interested in being able to run a single Nextcloud codebase for dozens or 1000s of vhosts on the same server?


I think this is awesome idea and something I’ve been waiting to happen for long time.
Sorta Wordpress Multisite solution for Nextcloud is a must.

Good timing, ownCloud has just published a blog post that they support multi-tenancy, but that has apparently all be done behind closed doors since my effort to introduce the feature was never officially fulfilled.

This was the start of a previous attempt by someone else at making things easier:

Reading about autoconfig.php is recommended, so is looking at the code of the last owncloud Snap since oC is installed on a RO partition, while the data is on a RW one.

I would have a use for multi-tenancy. Are you talking about each vhost being segregated from the other, or multiple vhosts sharing the same Nextcloud? I’m assuming the former.

What is crucial is how we allow administration of it.

If I understand what you mean, no, not like Wordpress’s idea of multihosting where the “sites” are virtual all using the same database. I mean simply a single copy of the Nextcloud codebase installed anywhere on the server and each vhost instance has it’s own webroot and files/ area with an individual database per site. I tried using symlinks for generic files and folders and made a real copy of the other folders needed per site (this was 2 months ago now so I have forgotten exactly which files and folders were symlinks and which were real copies) and the only problem with this simplistic approach was that some of the core PHP files user $cwd = dirname(dirname(__FILE__) which became relative to the symlinked destination rather than where the symlink was created in each vhost area. I think I searched for less than a dozen places where the code could be changed to using, say, $cwd = $_SERVER['DOCUMENT_ROOT'] instead and then everything could then work relative to the current web docroot and not prevent the current mode of operation from also working.

Wordpress itself could also do this as long as it’s ABSPATH const was dynamically assigned in 3 or 4 places!

It would be amazing to do a git pull in one codebase per server and be able to keep any number of vhost sites uptodate.

1 Like

Apologies if it’s not polite to bump an old topic like this but, for me, it is still 100% relevant and unresolved. NC13 is looking like a good place to seriously jump in but I am still terrified of having to manage 100’s of virtual hosts on my main server, each with their own branded instance of NextCloud. I do not have a test dev installation yet so I am wondering if those that are more intimately aware of current development have any hints that running multiple virtual hosts with their own config/config.php (hence different datadirectory and database details) but all running from a single root:gid-owner (f 640, d 750) owned codebase is possible these days?

1 Like

No harm in bumping your own topic chap, maybe don’t let a year go by between bumps if you can help it though :wink:

If there isn’t already, create an issue on NC github: with your detailed request (copy/paste from here is fine I think) and the devs will see it much faster.

So let’s bump this in only 3 months instead of over a year :slight_smile:

@JasonBayton I finally got around to doing as you suggest…