Install ASP.NET Core on Linux and Configure it to Serve a Web Application

Download Ubuntu server 18.04 from here and install it.

Install ASP.NET Core

First install ASP.NET Core 2.2 on the Ubuntu Linux machine. Issue these commands from a directory with write permissions:

wget -q
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install aspnetcore-runtime-2.2

Install and Configure Apache Web Server

Issue these commands to install and configure Apache as a proxy.

sudo apt-get update
sudo apt-get install apache2
sudo a2enmod proxy proxy_http proxy_html
sudo nano /etc/apache2/sites-enabled/000-default.conf

With a hashtag (#), comment out all the lines until just these remain or have been added:

NANO Edit 000-default.conf:

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

Install and Configure Samba Server

Install and configure Samba with these commands:

sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf

Create the new share [www] in this file.

NANO Edit smb.conf:

only guest=no
create mask=0777
directory mask=0777
guest ok=yes

Edit access rights for /var/www and reboot the Linux server.

sudo chmod 0777 /var/www
sudo reboot

Create a Web Application

Create an ASP.NET Core Web Application (MVC) in Visual Studio. Call it "app" for the purposes of this tutorial. Publish it as File System for Linux-x64 and Framework-Dependent.

Copy the published files to the Linux machine using its Windows share www. Copy the files into a directory named app.

Install and Configure Supervisor

Supervisor will automatically run the "app" everytime the machine starts. Issue these commands to install and configure Supervisor:

sudo apt-get install supervisor
cd /etc/supervisor/conf.d
sudo touch app.conf
sudo nano app.conf

Enter this text into the file.

NANO Edit app.conf:

command=/usr/bin/dotnet /var/www/app/app.dll

Reboot the machine and try accessing it from a web browser (http://ipaddress/). It should load the app and return its web pages.

To stop the "app" so that new files can be copied to the Linux server, issue this command:

sudo service supervisor stop

To start the "app" after new files have been copied over, issue this command :

sudo service supervisor start