Is it possible to have multiple instances of the same Kirby site with different content (and accounts). I’m looking to offer multiple clients an “engine” as a service that they can use without having to have a copy of the site on their servers. They would only host their own content, but the logic would be centralized and hidden in my server.
Following this recipe, I’m guessing something like this could potentially work:
/client1.com
/content
/kirby -> symlink to /engine.com/kirby
/site -> symlink to /engine.com/site
/client2.com
/content
/kirby -> symlink to /engine.com/kirby
/site -> symlink to /engine.com/site
/engine.com
/kirby
/site
First, I understand symlinks don’t work across domains, so I would have to host all sites in one server. But OK, let’s say that’s an option.
Second, how do I deal with instance-specific parts of the code? /site/accounts for example? Would this folder structure solve that problem?:
/client1.com
/content
/kirby -> symlink to /engine.com/kirby
/site
/accounts
/blueprints -> symlink to /engine.com/site/blueprints
/config -> symlink to /engine.com/site/config
/templates -> symlink to /engine.com/site/templates
...
Apart from centralizing maintenance, which is convenient, one reason to do this is to not give away my code. Am I maybe missing a more simple/obvious approach to achieve this?
Not so familiar with that recipe, but there is also the standard way of setting up a multisite: Multisite configuration | Kirby CMS, where you can set all roots. That also assumes a single server.
/client1.com
/content <-- instance-specific content
/site/accounts <-- only accounts inside of /site/
index.php <-- with the code above
/client2.com
/content <-- instance-specific content
/site/accounts <-- only accounts inside of /site/
index.php <-- with the code above
/engine.com
/kirby <-- kirby for all sites
/site <-- the logic for all sites
This will only work when these folders are virtual hosts sitting on the same server - not across domains.
That’s not quite true. A “domain” is a DNS and HTTP concept that is irrelevant to PHP and to the operating system running your server (probably Linux).
At the operating system level, a symlink at /folder-a/site pointing to /folder-b/site should not be a problem. I’m expecting that this part works.
I expect that the issue you’re facing is from PHP and your PHP configuration. You may be using a host that manages “sites” or “domains” as different folders, each with its unique PHP configuration. And those configurations probably set the open_basedir config to a specific folder. When using something like require 'kirby/index.php'; the symlink for the ‘kirby’ folder is followed and resolved to a path that is outside the open_basedir.
Note that you don’t need symlinks if you configure the Kirby roots (as shown in your second message), but you will still run into the same PHP configuration restrictions.
This can be worked around by listing several directories in open_basedir, in the relevant php.ini (or wherever PHP is configured for a site/domain):
Note that there might be other PHP configuration values that don’t like requiring PHP code from different locations; open_basedir seems like the most likely culprit, but I’m not a PHP configuration expert ^^
Hey @fvsch, thanks for going more in depth with the technical aspect of the matter. I don’t know much server stuff, so your message helps make sense of things.
You’re right, symlinks are not necessarily limited by domains, as, like you said, a domain is a DNS and HTTP concept, irrelevant to PHP. I guess what I was trying to say is symlinks don’t work across different servers, but correct me if I’m wrong.
To clarify, the code in my second post is working fine for me - there’s no PHP config issue.