Deploy Piranha CMS to ubuntu

Piranha CMS is a open source CMS based on Asp.Net core. It means we can host it on a Linux based system or any other system that support dotnet core.

We need the following stuff:

Dotnet core 3.1

Follow this page to install the dotnet core sdk. 

Piranha CMS

Follow this page to setup Piranha CMS. You can setup the CMS project at your local first and deploy to the server when everything is ready. 


Ubuntu have Apache 2 install by default, so no need to install seperately. Apache2 will be used as reverse proxy server. Beside from this there are servals other options we can use, such as Nginx, Haproxy. You even can use Kestrel directly if you prefer.


Piranha CMS is using SQL Lite as database by default, it's enough for a personal site.

1. Setup a new website in Apache 2

<VirtualHost *:80> 
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
ProxyPreserveHost On   
ProxyPass /   
ProxyPassReverse /

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

The following are 2 mandatory modules we need: 

HTTP and HTTP_Proxy

Enable the modules:

sudo a2enmod http
sudo a2enmod http_proxy

After enable the moules, restart the Apache 2:

sudo /etc/init.d/apache2 restart

2. Modify the Project

Kerstrel is the real web server we used to host Asp.Net core project in Linux and we use Apache 2 in front of it. We need to let Kerstrel know about this.

Open the Startup.cs file, find Configure method, add the following code:

app.UseForwardedHeaders(new ForwardedHeadersOptions(){

3. Create a deployment package

dotnet publish --configuration Release

4. Copy everything in publish folder to your server. Be sure to copy the database file too.

5. Start Kerstrel to receive the request from Apache 2

dotnet blog.dll --urls http://localhost:5010

Kerstrel use 5000 as default port. We can change it by using urls parameter. The dll name probably different, it actually is your CMS project name.


Create a service to start the Kesterl server automatically

sudo nano /etc/systemd/system/kerstel-blog.service

Following is the service file example:

Description = Achievecreative Blogs

ExecStart=/usr/bin/dotnet /var/www/achievecreative/blog.dll --urls http://localhost:5010
# Restart service after 10 seconds if the dotnet service crashes:
User={replace with your user name}


Enable and start the service:

sudo systemctl enable /etc/systemd/system/kerstel-blog.service
sudo systemctl start kerstel-blog.service