How multisite works?

Can someone voluntarily introduce me to how multisite works and how it’s supposed to be implemented.

I read
But it assumes one understands it in advance.
I can copy/paste that, then what is supposed to happen, what should I expect?


I’ve never tried that, but if I understand it correctly, you basically have a single Kirby installation, only your /site, /content, thumbs/ and /assets/avatars folders contain subfolders for each domain, e.g.



You need to provide a site.php with the code as laid out in the example. Kirby then automatically fetches the right stuff for each domain.

I use this setup to run a hosted version of Shopkit for a few clients.

Essentially the root /content folder gets deleted, and instead I have


So that gives me common folders used by all three sites, so the core/assets/templates/blueprints/panel can all be updated at once.

With the setup above, every client can manage their own content, but all three sites are actually being powered by the same core/template/plugin files.

1 Like

Do you use multiple domains, or you are separating local content?

Thank you. The idea sounds useful to me.

I followed the docs example, but don’t know what to expect really.
I don’t know if I have the same idea of “multisite”.

Nothing happens after I create /site.php.
So I guess I don’t get the picture.

Ok, I briefly tested this locally with Mamp and got it to work:

  1. Use the example site.php and put it into the root of your kirby install. Change domains to fit your setup, I used fake domains called and

  2. Create subfolders with those domain names like I explained above, i.e.




  1. I used the starterkit as a basis, so I moved all the stuff from the original /site and /content folders into /content/ and site/ and then copied and pasted the stuff into the /content/ and /site/

  2. In my /etc/hosts file I added the following lines:

In my httpd-vhosts.conf file I added the Virtual hosts (Mamp/conf/apache/extra):

<VirtualHost *:80>
    DocumentRoot "/Applications/Mamp/htdocs/multisite"

<VirtualHost *:80>
    DocumentRoot "/Applications/Mamp/htdocs/multisite"

Now I can access the Kirby installation in my browser by calling

You would probably have to enable vhosts in your httpd.conf file.

If you use another setup, you have to adapt this to test it.

Make some changes to any of the installs to experience the difference.

Hope this helps.

Yep, three different domains. They’re not connected in any way other than using the same core files.

THAT is a significant piece of setup.
I would have never guessed that.
Let me try it and see what comes out of it.

First time trying this.
Sounds very interesting.

@heyallan: If you don’t need different templates etc. you can also use a setup as described by @samnabi. In that setup, only the content folder is different for the domains, all the rest (templates, snippets, configuration, thumbs etc.) is shared by the different domains.

Or, just add a templates/ folder under client-one, client-two, etc…

Since the folder locations are defined in site.php, you can really have any folder structure that makes sense to you.

@samnabi Yes, that’s right, but what I meant to say was that if you want to share templates across sites, you don’t need to have different template folders (no matter where you put them).

Thank you both :thumbsup:

How does your site.php looks like?
I’m interested in something like that.

// site.php

$kirby   = kirby();
$domain  = server::get('server_name');

// Invalid subdomain redirects to
$clients = array_diff(scandir(__DIR__.'/shops'), array('..', '.','.DS_Store'));
if (!in_array($domain, $clients)) {
    $client = '';
} else {
    $client = $domain;

// custom roots
$kirby->roots->content = __DIR__ . DS . 'shops' . DS . $client . DS . 'content';
$kirby->roots->avatars = __DIR__ . DS . 'shops' . DS . $client . DS . 'avatars';
$kirby->roots->thumbs  = __DIR__ . DS . 'shops' . DS . $client . DS . 'thumbs';
$kirby->roots->accounts  = __DIR__ . DS . 'shops' . DS . $client . DS . 'accounts';

// custom urls
$kirby->urls->index    = url::scheme() . '://' . $client;
$kirby->urls->content  = $kirby->urls->index . DS . 'shops' . DS . $client . DS . 'content';
$kirby->urls->avatars  = $kirby->urls->index . DS . 'shops' . DS . $client . DS . 'avatars';
$kirby->urls->thumbs   = $kirby->urls->index . DS . 'shops' . DS . $client . DS . 'thumbs';

Very useful.
I think I’m getting the picture.

@texnixe Yes, it works as described.

I can make, and, use same installation with custom folders (I’m on MAMP)

Except httpd-vhosts.conf, and httpd.conf, don’t have any visible effect.
I played with those, but nothing changes.

I read tutorials about vhosts and I think I’m doint it right.
But I’m worried about vhosts not working (?).

Do you mean, it works without setting the virtual hosts? Have you restarted Apache after making those changes?

I think it worked like this because /etc/hosts file takes both domains to, that’s where MAMP is running with a kirby installation. Then site.php handles both domains. Good.

I think vhosts settings didn’t take any effect because it assumes port :80, and I had MAMP set to default :8888, I made them match and it worked. There’s tricky configurations everywhere.

In my case, I’m interested in having same kirby installation for both domains.
Then… if hosts, and site.php, makes it all work seamlessly, is vhosts really necessary?

I get the feel that vhosts is used in other kind of websites where no site.php exist, or where domains will contain separate contents.

I’m new to this, I’m not sure if I’m getting it right.

In my experience, no, vhosts isn’t necessary if you want all domains to go to the same place.

Makes sense!
Thank you very much!