安装nginx

sudo apt-get install nginx

sudo service ngnix start

https://github.com/Microsoft/dotnet-core-sample-templates/blob/master/dotnet-core-music-linux/music-app/nginx-config/default

cd /etc/nginx/sites-available
sudo vim default
server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
sudo nginx -t  # test

sudo nginx -s reload

dotnet run linux 缺失文件

Microsoft.ApplicationInsights.AspNetCore.dll is missing

 An assembly specified in the application dependencies manifest (MyApp.deps.json) was not found:
    package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
    path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll'

  This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
    aspnetcore-store-2.0.3.xml

I have arch linux (not officially supported).

dotnet new empty
dotnet publish -o ./published
dotnet published/<ProjectName>.dll
and that error is presented

but

//I added runtime identifier for linux
dotnet publish -o ./published -r linux-x64
dotnet published/<ProjectName>.dll
this works.

So perhaps try to specify runtime identifier -r linux-x64 when you publish your application.

https://github.com/dotnet/coreclr/issues/13542

–> https://github.com/aspnet/aspnet-docker/issues/286

Workaround also works for Ubuntu. Seems like you have to specify your target runtime environment:

dotnet publish -c release -o publish -r linux-x64

This is not the case when using the SDK

dotnet core ubuntu

dotnet publish -c release -o publish -r linux-x64

nohup dotnet run -c release &

ps -e --sort=cmd, 按进程名排序(默认是按 进程id排序)

sudo service supervisor restart, 重启监控进程

[program:WebApplication1]
command=/usr/bin/dotnet /home/robin/publish/WebApplication1.dll
directory=/home/robin/publish
autostart=true
autorestart=true
stderr_logfile=/var/log/NetCoreBBS.err.log
stdout_logfile=/var/log/NetCoreBBS.out.log
environment=ASPNETCORE__ENVIRONMENT=Production
user=root
stopsignal=INT

sudo tail -f /var/log/supervisor/supervisord.log view supervisor log

tail -f /var/log/hellomvc.out.log, view asp net core app log