ASP.NET Core Installation on Linux

1.      Publish from Visual Studio.

a.       From solution explorer, right click on the main project, then click Publish.

b.      On the opened tab, Click Configure.

c.       On the new open window, on connection tab,  pick Publish method "File System", set your target location, then click "Next".

d.      On the configuration tab, pick the configurations:

·   Configuration: "Release".

·   Target Framework: "netcoreapp2.1".

·   Deployment Mode: "Self-Contained". (this is part is essential option).

·   Target runtime: "linux-64".

·   Click Save.

e.      Click Publish.

f.        After it is finished publishing the apps, go to publish location that you have been set on the previous step.

g.       The application files ready to upload to server, it would be better if you zip is first.

2.      Upload Application Files.

a.       Go to https://yourdomain.com:2083, and login with your given username.

b.      On the dashboard, click "File Manager".

c.       From your home directory, create a directory or existing directory to upload. It does not necessary to put the application files in public_html directory. then click

d.      Click upload, and select your application files, then click send.


3.      Configure .htaccess.

a.       Click Edit to edit .htaccess file or create it if it is not there.

b.      Add this line:

RewriteEngine On

RewriteRule .* http://127.0.0.1:40000/ [P,L]

·         .* is your website path, you can change it, ie: full path http://www.mydomain.com/article, the replace .* with /article.* (note if you put /article, every request without /article will not redirected (not found), if this is necessary for you, you can add another line rewrite configuration on .htaccess, see documentation

·         20000 is your given local port  number, it should be unique.

c.       If you using websocket, then use this line:

·   RewriteEngine On

·   RewriteCond %{HTTP:Connection} Upgrade [NC]

·   RewriteCond %{HTTP:Upgrade} websocket [NC]

·   RewriteRule .* ws://127.0.0.1:40000/ [P,L]

4.      Run Kestrel Service from SSH Login with nohup.

a.       You should have permission to run dotnet command.

b.      using nohup will keep the kestrel service of your application keep running even you logout from SSH, see here for more detail.
type:

sudo nohup dotnet /home/username/folder/webapplication1/webapplication.dll --server.urls=http://localhost:40000 --verbosity m >/dev/null 2>&1 &

c.       to test type: curl http://localhost:40000, or open your browser, type yourdomain.com.

5.      Stop restart Kestrel service.

a.       You need to stop your apps kestrel service manually when you have an update.

b.      type ps -ax.

c.       find the process Id of your dotnet command.

d.      sudo kill 12312

e.      After you copy your updated files, run again the service on #4.