1、安裝 libicu 依賴 1、線上安裝 顯示如下信息表示成功 2、離線安裝 將文件aspnetcore runtime 2.2.1 linux x64.tar.gz複製到 /usr/local/dotnet 3、添加環境變數 這個時候能看到所有的環境變數,找打並複製PATH一行,大概是下麵這樣。 ...
1、安裝libicu依賴
1、線上安裝
sudo mkdir /usr/local/dotnet #創建目錄
cd /usr/local/dotnet
sudo wget https://download.visualstudio.microsoft.com/download/pr/53cace8f-2907-487e-84d7-bc7a7ba5de05/326704ffa2ef9d4dcd0db2f1da996ebb/aspnetcore-runtime-2.2.1-linux-x64.tar.gz # 下載離線安裝包
sudo tar -xvf aspnetcore-runtime-2.2.1-linux-x64.tar.gz # 解壓
./dotnet --info #查看
顯示如下信息表示成功
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [/home/allspark/Downloads/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [/home/allspark/Downloads/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [/home/allspark/Downloads/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
2、離線安裝
sudo mkdir /usr/local/dotnet #創建目錄
將文件aspnetcore-runtime-2.2.1-linux-x64.tar.gz複製到 /usr/local/dotnet
sudo tar -xvf aspnetcore-runtime-2.2.1-linux-x64.tar.gz # 解壓
./dotnet --info #查看
3、添加環境變數
env #查看所有環境變數
這個時候能看到所有的環境變數,找打並複製PATH一行,大概是下麵這樣。不要直接複製這裡的,這裡只是例子。PATH=/home/allspark/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
sudo vi /etc/profile #編輯/etc/profile文件,就是環境變數文件
在最下麵追加
export 你剛剛複製的:/usr/local/dotnet #輸入,:wq保存退出,
例如:
export PATH=/home/allspark/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/dotnet
source /etc/profile #立即生效環境變數
dotnet --info # 出現以下內容說明安裝正確。如果輸入沒有正確,斷掉ssh登錄,重新連接,再次輸入命令
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [/usr/local/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [/usr/local/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [/usr/local/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
4、運行測試代碼
將發佈好的代碼複製到伺服器
dotnet 你的項目.dll
例如我的
dotnet WebApplication1.dll
訪問你程式的埠