首篇筆記,多多關照,方便回憶和給新手指導,大神繞道
首先在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
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/149757.html
標籤:Linux
