A guide to asp.net core in Linux
In this article, I will show how we can start host asp.net applications in the Linux platform.
I used this following application https://github.com/sajidur/Donor , You can also be used this repo
Here I used RedHat Enterprise you can also be used Ubuntu.
So let's prepare our server to host the applications with follow below step
- Install any SSH Client to access your server. You can use PuTTY . Download from here https://www.putty.org/
- Install any FTP Client. You can use WinSCP. Download from here https://winscp.net/eng/docs/guide_install
- Now follow this link to install .net core SDK/runtimes https://access.redhat.com/documentation/en-us/net_core/3.1/html/getting_started_guide/gs_install_dotnet
We are done. So let's focus on our repository
First, we need to publish our .net core app for Linux.
We can use Visual studio published options. To create a publish profile with the following types
Or you can use the command
$ dotnet publish -f netcoreapp3.1 -c Release
Secondly, After publish we will upload our publish folder to the server with WinSCP(or any FTP client) and navigate to the folder with SSH
After that run following command to start your applications. Application will be running in Kestral server
$ scl enable rh-dotnet22 bash
$ dotnet donor.dll
So we are done. Let's browse our application in the browser
Now the problem is when you close/exit your ssh application will stop. So we will use tmux to hold our session running.
To do that first we need to setup tmux in server with following the link below
And also your application need to run after an open session with tmux in your ssh client.
$ tmux new -s [name]
$ scl enable rh-dotnet22 bash
$ dotnet donor.dll
Now close your session with Cltr+d and check your application still running.
You can reuse this session or kill by the following command
$ tmux new -s [name]
$ tmux kill-session -t [session name/index]
$ tmux attach-session -t my_session
Some important basic command for non linux user
sudo fuser -k 8000/tcp
Also you can check another article for configuring reveres proxy with apache