添加镜像订阅

rpm --import https://packages.microsoft.com/keys/microsoft.asc
sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'安装SDK
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.1.3查看安装
dotnet --versionpsftp [主机地址]
put D:\website.7z解压文件,使用的是 p7zip
7za x website.7z创建服务
vi /etc/systemd/system/website.service[Unit]
Description=Web API Application running on CentOS
[Service]
WorkingDirectory=/home/website
ExecStart=/usr/bin/dotnet /home/website/website.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=website
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target启动服务
systemctl start website systemctl enable website测试站点
curl localhost:8010yum install -y nginx启动,测试
systemctl start nginx nginx -v修改配置文件
cd /etc/nginx
vi /etc/nginx/conf.d/vhost_website.confserver {
server_name [test.xxx.com];
root /home/website;
location / {
proxy_pass http://localhost:8010;
}
}重新加载
systemctl restart nginx浏览器打开
http://[test.xxx.com]1.Unable to bind to http://localhost:5000 on the IPv6 loopback interface: ‘Error -99 EADDRNOTAVAIL address not available’.
添加hosting.json
{
"server.urls": "http://*:8010" }修改Program
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseStartup()
.Build()
.Run();
}