Proving the concept

Proof of Concept for .NETCore on Ubuntu 18.04.

Well if you can see this, then hosting .NETcore on Ubuntu is functioning

Well worth reading Publishing and running your ASP.NET Core project on Linux but to summarise

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.debwget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.debwget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

sudo add-apt-repository universe

sudo apt-get update

sudo apt-get install apt-transport-https

sudo apt-get update

sudo apt-get install dotnet-sdk-3.0

sudo pico /etc/systemd/system/kestrel-aspnetcoredemo.service

[Unit]
Description=Example ASP .NET Web Application running on Ubuntu 18.04
[Service]
WorkingDirectory=/var/www/www.domain.ext
ExecStart=/usr/bin/dotnet /var/www/www.domain.ext/aspnetcoredemo.dll
Restart=always
RestartSec=10
SyslogIdentifier=dotnet-demo
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target

sudo systemctl enable kestrel-aspnetcoredemo.service

sudo systemctl start kestrel-aspnetcoredemo.service

sudo a2enmod proxy proxy_http proxy_html

sudo systemctl daemon-reload

If you need a different version of the runtime then:

sudo apt-get install aspnetcore-runtime-2.1

and you will need to add a virtual host conf file in /etc/apache2/sites-available/www.domain.ext.conf

<VirtualHost *:80>
ServerAdmin serveradmin@domain.ext
ServerName www.domain.ext
ServerAlias domain.ext
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ErrorLog /var/log/apache2/aspnetcoredemo-error.log
CustomLog /var/log/apache2/aspnetcodedemo-access.log

Visual studio (17) - Publish your project and then copy the content of your projects bin\Release\[.netcoreapp(ver)] folder i.e. dlls etc to your kestrel.service WorkingDirectory
and then your projects wwwroot folder into the same WorkingDirectory.
restart your kestrel service (sudo service kestrel-aspnetcoredemo restart).