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

黄舟
發布: 2017-09-25 11:13:46
原創
5473 人瀏覽過

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

  • 安裝CentOS

  • #.Net core for Linux

  • 建立Asp.net Core應用程式

  • #安裝Nginx

  • ##設定Nginx代理程式<span style="font-size: medium;"></span>

1,<span style="font-size: medium;"></span>安裝CentOS系統<span style="font-size: medium;"></span>

這個網路教學太多濾過。 <span style="font-size: medium;"></span>

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

 

2,安裝跨平台的.NET Core SDK for CentOS7<span style="font-size: medium;"></span>

  • 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應用程式<span style="font-size: medium;"></span>

dotnet new web<span style="font-size: medium;"></span>

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

由於需要虛擬機器外部存取得修改預設的localhost設定:<span style="font-size: medium;"></span>

vi Program.cs<span style="font-size: medium;"></span>

新增UseUrls(“http://*:5000”)<span style="font-size: medium;"></span>

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

發佈並測試<span style="font-size: medium;"></span>

dotnet publish –c release<span style="font-size: medium;"></span>

dotnet TestAspnetCore.dll<span style="font-size: medium;"></span>

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

#重點:設定防火牆<span style="font-size: medium;"></span>

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上部署的圖文詳解

#虛擬機器外部存取確認<span style="font-size: medium;"></span>

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

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

<span style="font-size: medium;"></span>

<span style="font-size: medium;"></span>

<span style="font-size: medium;"></span>

<span style="font-size: medium;"></span>

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

<span style="font-size: medium;"></span>

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

<span style="font-size: medium;"></span>

#4虛擬機器

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

4,安裝Nginx

<span style="font-size: medium;"></span>

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中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!