前言
本文介绍如何在 Ubuntu 16.04 服务器上部署 ASP.NET Core 2.0 Web 项目。
安装 .NET Core
注册 Microsoft 签名密钥:
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
注册软件源
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
安装 .NET SDK
在终端管理器下,运行以下命令:
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.2
Nginx 的安装与启动
更新源
sudo apt-get update
安装 Nginx
sudo apt-get install nginx
启动 Nginx
通过运行以下命令显式启动:
sudo service nginx start
配置 Nginx
server {
listen 80;
location / {
proxy_pass http://localhost:8000;
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;
}
}
参考文章
1.使用 Nginx 在 Linux 上为 ASP.NET Core 设置托管环境,并对其进行部署
2.Get started with .NET in 10 minutes