首頁  >  文章  >  後端開發  >  Asp.net Core應用程式在Linux上部署的圖文詳解

Asp.net Core應用程式在Linux上部署的圖文詳解

黄舟
黄舟原創
2017-09-25 11:13:465361瀏覽

快兩個月沒接觸.net,倒是天天在用Linux,所以想試試在Linux運行喜歡的.net 應用。

  • 安裝CentOS

  • #.Net core for Linux

  • 建立Asp.net Core應用程式

  • #安裝Nginx

  • ##設定Nginx代理程式

1,安裝CentOS系統

這個網路教學太多濾過。

Asp.net Core應用程式在Linux上部署的圖文詳解

 

2,安裝跨平台的.NET Core SDK for CentOS7

  • sudo yum update

  • sudo yum install libunwind libicu

  • #sudo yum install dotnet-sdk-2.0.0

Asp.net Core應用程式在Linux上部署的圖文詳解

dotnet --info可以確認是否安裝成功

Asp.net Core應用程式在Linux上部署的圖文詳解

 

#3,建立Asp.net Core應用程式

dotnet new web

Asp.net Core應用程式在Linux上部署的圖文詳解

由於需要虛擬機器外部存取得修改預設的localhost設定:

vi Program.cs

新增UseUrls(“http://*:5000”)

Asp.net Core應用程式在Linux上部署的圖文詳解

發佈並測試

dotnet publish –c release

dotnet TestAspnetCore.dll

Asp.net Core應用程式在Linux上部署的圖文詳解

#重點:設定防火牆

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --permanent --zone=public --add-port=5000/tcp
sudo firewall-cmd --reload

Asp.net Core應用程式在Linux上部署的圖文詳解

#虛擬機器外部存取確認

Asp.net Core應用程式在Linux上部署的圖文詳解

Asp.net Core應用程式在Linux上部署的圖文詳解

Asp.net Core應用程式在Linux上部署的圖文詳解

Asp.net Core應用程式在Linux上部署的圖文詳解

#4虛擬機器

Asp.net Core應用程式在Linux上部署的圖文詳解 

4,安裝Nginx

sudo yum install epel-release

Asp.net Core應用程式在Linux上部署的圖文詳解

sudo yum install nginx##################nginx –v 檢視版本####### ##################尋找Linux的IP位址,啟動Nginx服務####################虛擬機外部存取位址############備註:如果無法顯示這個頁面估計是防火牆沒有設定。 ################## #########5,設定Nginx代理程式######### ######### ######nginx詳細設定待續###

以上是Asp.net Core應用程式在Linux上部署的圖文詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn