首篇筆記,多多關照。方便回憶和給新手指導,大神繞道
首先在Linux系統部署.net Core項目首先准備一個Linux系統的服務器,百度雲,阿里雲都行。
1.net core 部署在Linux系統上運行的環境搭建總結
指導連接:https://www.cnblogs.com/hzzxq/archive/2018/11/13/9952341.html
2.發布項目到Linux
我這邊采用的是FTP傳入到Linux系統
1.在服務器home下面創建一個文件夾(文件名隨意),將編譯的文件發布到改文件下

3.配置Nginx

1.編輯conf文件,直接在文件下面復制粘貼下面這代碼
server {
listen 81;
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
注:訪問服務器81端口轉到Core項目
2.編輯好conf文件在服務端執行
nginx -s reload
使其生效,也先執行 nginx -t 看一下配置文件是否配置有誤。

ok,說明沒語法錯誤。
4.運行.net Core項目
出現 502 Bad GateWay 有可能是項目沒運行(Layui_Demo為項目名稱,你這邊換成你自己的項目名即可)

注意:不要Ctrl+C,Ctrl+C項目就終止了。
現在去瀏覽器訪問http:服務器IP:81 就OK了
附:
可以使用下面的命令來讓一個命令行運行在后台進程中。
nohup dotnet Layui_Demo.dll &
jobs
查看當前終端后台運行命令 ,終端關閉后無法查看。
kill %數字
終止當前程序
5.相關問題
Failed to load ¸U㪠error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.5/libcoreclr.so'
解決;
yum install libunwind
