Installation of dotnet on CWP server :

First install .net package repo from official Microsoft site :

rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

To install dotnet SDK 2.2

yum install dotnet-sdk-2.2 -y

To install dotnet SDK 3.1 LTS :

yum install dotnet-sdk-3.1 -y

you can check the main dotnet version by running this command :

dotnet --version

How to Create project - example:

to create a project or download any existing prebuild project you need to follow this steps:
Login into ssh with the username of your account user (ensure you enabled the full shell access for that user)
or from root you can run this command to change the user :

su - username -s /bin/bash

now go to user dir public_html:

cd /home/username/public_html

Download pre build ASP core project, we're using "movie-app-list" as an example :

git clone https://github.com/do-community/movie-app-list.git movie-app-list

Then enter the project dir :

cd movie-app-list

before we do the configuration this project needs MySQL DB and MySQL User for its data storage, you can simply create MySQL user and DB from user panel as well as admin panel.

after you create db and its user add those details in "appsettings.json"

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "MovieContext": "Server=localhost;User Id=user_netdb;Password=dqrESQo3;Database=user_netdb" } }

Now build the application :

you need to run this as root :

dotnet ef database update
dotnet build
dotnet publish

**upper commands will install csharp and all other dependencies.

Then fix the user permission :

cd /home/username/public_html
chown -R username:username *

Now again login to ssh as user and run the below command to start the application by default application is set to run on localhost:5000

Now start the application via this command :

$ su - username -s /bin/bash
$ /usr/bin/dotnet /home/username/public_html/movie-app-list/bin/Debug/netcoreapp2.2/publish/MvcMovie.dll

After that Ensure you've installed Nginx from CWP for port 5000 proxy go to :

ADMIN >> Webserver Settings >> Webserserver domain conf >> Choose user >> Create config under domain you need to proxy dotnet application >> Choose "nginx -> proxy -> (custom-port)" and choose force https template tick rebuild vhost and save changes and done.

* don't forget to set your app port!

go to the domain name and see your application is live there.

Troubleshoot guide :

If you get too many files open you simply need to increase the open file limit for the user from edit user account.

Tagged: