Contribute to Docs Contribute to Docs

How To Use Multitenancy

Piranha has support for multitenancy although there are some restrictions that you need to consider:

  • You cannot restrict content types per site - This means that if you had a single Piranha CMS site with two companies (Company A and Company B) then both companies would share the same content types.
  • You cannot restrict users to a single site - This means that you cannot have a user who is only able to edit one site.
  • You cannot restrict sites to a single media library - This means that all sites will share the same images.

If you are happy to accept these restrictions, then this guide will show you how to set up a single Piranha CMS instance and have two websites running on it.

For this demo, we are going to use the default Piranha CMS websites that come with the source code. This is the one where you have a Default and Swedish sites. We are going to setup a website called which will point to the Default site and which points to the Swedish website. We will use the multitenancy feature to change the homepages and show different content on each site.

Add Host Entries

First of all, you need to create host entries into your Windows hosts file. We are going to point and websites to your local machine and we will use the multitenancy feature in Piranha to display these websites.

Open the hosts file using Notepad which in the c:\Windows\System32\drivers\etc\ folder. Remember, you will have to run Notepad in administrator mode in order to be able to edit the hosts file.

Now add these two new lines to the bottom of the file:

Configure The Sites

Now we need to tell the Default site in Piranha that it should run on To do this, login to the Piranha Manager and click on "Default site" to open up the "Edit site" modal. In the hostnames textbox, enter and then click save. Remember, you should not add the http prefix, just the hostname. Close the modal when you are finished.

Next, click the "Home" page and add "Hello from the default site" in the main context block so that you can see it's on on

Go back to the Pages view and click on Swedish. In the hostname box enter and click save. Again, edit the main content block and add "Hello from the Swedish site" so you can see this is

Test It In Your Browser

By default, the Piranha websites will run on port 5000.

Start the application and when it's ready, enter in your browser. You should see "Hello from the default site" on the page.

Now, go to and you will see "Hello from the Swedish site" on the page!

You can now add pages to either site and can even copy pages between the two sites.