# Multiple "instances" of the same Kirby site

**URL:** <https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800>\
**Category:** Questions\
**Tags:** v5\
**Created:** [March 17, 2025, 12:20pm UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800 "2025-03-17T12:20:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 17, 2025, 12:20pm UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800/1 "2025-03-17T12:20:59Z")

</div>

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.

To better explain, I’m imagining this structure:

```auto
/client1.com
  /content
/client2.com
  /content
/engine.com
  /kirby
  /site

```

Following this [recipe](https://getkirby.com/docs/cookbook/development-deployment/multisite-variant), I’m guessing something like this could potentially work:

```auto
/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?:

```auto
/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?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 17, 2025, 12:52pm UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800/2 "2025-03-17T12:52:38Z")

</div>

Not so familiar with that recipe, but there is also the standard way of setting up a multisite: [Multisite configuration | Kirby CMS](https://getkirby.com/docs/guide/configuration/multisite-setup), where you can set all roots. That also assumes a single server.

---

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 18, 2025, 11:04am UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800/3 "2025-03-18T11:04:16Z")

</div>

Aha. Thanks for the lead @texnixe!

I made my setup work with this on `/index.php`:

```auto
$engine = '../../engine.com/htdocs/';
$url = __DIR__. '/';

require $engine . 'kirby/bootstrap.php';

$kirby = new Kirby([
	'roots' => [
		'index' => $url,
		'site' => $engine . 'site',
		'accounts' => 'site/accounts',
		'content' => 'content',
		'media' => 'media',
		'assets' => $engine . 'assets'
	],
	'urls' => [
		'media' => $url . 'media',
		'assets' => $url . 'assets',
	],
]);

echo $kirby->render();

```

The folder structure is like this:

```auto
/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.

---

<div class="post-metadata">

**Author:** ![fvsch](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/fvsch/32/15908_2.png) [@fvsch](https://forum.getkirby.com/u/fvsch)\
**Post date:** [March 21, 2025, 3:00pm UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800/4 "2025-03-21T15:00:13Z")

</div>

> [@daizumi](#):
>
> First, I understand symlinks don’t work 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):

```ini
open_basedir = "/client1.com/:/engine.com/"

```

Docs: [PHP: Description of core php.ini directives - Manual](https://www.php.net/manual/en/ini.core.php#ini.open-basedir)

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 ^^

---

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 26, 2025, 10:12am UTC](https://forum.getkirby.com/t/multiple-instances-of-the-same-kirby-site/33800/5 "2025-03-26T10:12:16Z")

</div>

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.
