Skip to content

Hosting Core application on Linux using runtime and Apache core can be hosted on Windows as well as Linux. Hosting on windows is very easy and you can find plenty of resources for windows hosting. Microsoft documentation have also good walk through for Linux hosting, but they all use .Net SDK installation. But to run on production, minimal requirement is only .Net core runtime. So in this tutorial, I will show you how you can host core application on Linux, using only core runtime and Apache.

This will be helpful if you have existing other technology based websites, like WordPress blog etc. and you want to host core application side by side.

I am using Ubuntu 16.04. I assume you have already installed Apache on your Linux server.

We need to perform following steps:

  • Install core runtime on Linux server.
  • Enable mod_proxy in Apache if not already enabled.
  • Create Virtual Host for your website.
  • Deploy core application on server.
  • Installing supervisor to keep the website running.

Install Asp.Net Core runtime

First download the .net core runtime from and extract it.

wget <a href=""></a>
tar -xvzf dotnet-runtime-2.0.0-linux-x64.tar.gz -C /var/dotnet

We will also need core store packages, so download and extract it inside the extracted runtime folder.

wget <a href=""></a>
tar -xvzf aspnetcore.runtimestore.tar.gz -C /var/dotnet

Here i have used for core 2.0. You can use other version as per your requirement. Go to and click on the version of your choice. After that you will get options similar to following image. It may change in future, web apps always changes. core runtime download page core runtime download

Enable mod_proxy in Apache

If mod_proxy is not enabled, then you need to enable it, because core website will run as reverse proxy to Apache. Execute following commands:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests

Here are the details of what works these modules do:

  • mod_proxy, the main proxy module Apache module for redirecting connections; it allows Apache to act as a gateway to the underlying application servers.
  • mod_proxy_http, which adds support for proxying HTTP connections.
  • mod_proxy_balancer and mod_lbmethod_byrequests, which add load balancing features for multiple backend servers.

Create Virtual Host for website

We need to create virtual host file, to instruct apache to run core as proxy. Create a new conf file for your application with following content. From here on, replace with your domain name.

sudo nano /etc/apache2/sites-available/

Add following setting in this file.

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass /
    ProxyPassReverse /

    LogLevel warn
    ErrorLog /var/www/html/
    CustomLog /var/www/html/ combined

Create folder structure where application files will be uploaded.

cd /var/www/html
sudo mkdir
sudo mkdir -p
sudo mkdir -p

Finally enable this new website.

sudo a2ensite

And now reload or restart the Apahe server.

sudo service apache2 restart

Deploy core application on server

Now it’s time to publish and deploy application on the server. I am going to upload the published file in to /var/www/html/ You can use any tool like filezilla to upload the files on the server.

Installing and configuring Supervisor

We need to keep our application running on the server, so we will use supervisor which will monitor and keep our application running.

sudo apt-get install supervisor

Now let’s create a configuration file for this website.

sudo nano /etc/supervisor/conf.d/

Put following setting in this file.

command=/var/dotnet/dotnet /var/www/html/

Now restart the supervisor service.

sudo service supervisor stop
sudo service supervisor start

To ensure if there is no error, you can see the supervisor log using this command. You could also use nano but this will show the latest status in the last of log file.

tail -f /var/log/supervisor/supervisord.log

That’s all completed. Now you can view your website from any computer.

Another way to host core website on Linux server is using Docker, but I’ll look into it next time.

One Comment

  1. hassan hassan

    how to deploy the publish .net 6

Leave a Reply

Your email address will not be published.