【Linux】使用Nginx发布dotnet的网站

1.安装Nginx【自行百度】

2.安装dotnet运行时【自行百度】

3.配置Nginx—— /etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    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;
    }
}

将5000端口映射到80端口

4.配置.net Core

    "Xuxml.Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

5.前4部是准备工作,完成了准备工作之后,上传网站的文件到服务器,进入网站目录结构下,敲发布代码

查看目录 ls
查看端口占用 netstat -ntlp
结束端口  kill -9 【端口号】
发布代码 nohup dotnet Xuxml.web.dll &netstat -ntlp

6.发布完成


如果有问题。欢迎各位大神指正呀!