centeros 部署 .netcore

1、安装运行时:
地址:https://www.microsoft.com/net/download/linux-package-manager/centos/runtime-2.1.1
2、安装sdk:
地址:https://www.microsoft.com/net/download/linux-package-manager/centos/sdk-2.1.301
3、安装nginx:

curl -o  nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx.rpm
yum install nginx
systemctl start nginx 启动nginx。
systemctl enable nginx 设置nginx的开机启动

4、配置防火墙:

firewall-cmd --zone=public --add-port=80/tcp --permanent(开放80端口)
systemctl restart firewalld(重启防火墙以使配置即时生效)

5、使用ftp软件上传程序:secureCrt上传很麻烦,经常出现was skipped错误,网站程序通常在var目录下,如:/var/aspnetcore/testmvc
6、检查程序是否能正常运行:

dotnet /var/aspnetcore/testmvc/testmvc.dll

查看是否正常访问:

curl http://localhost:5000

7、修改nginx配置文件:地址是 /etc/nginx/conf.d/default.conf,内容为:

server {
    listen       80;
    location / {
        proxy_pass http://localhost:5000;
        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;
    }

}

执行命令使配置生效

nginx –s reload

其他参考:
https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&tabs=aspnetcore2x

https://www.cnblogs.com/ants/p/5732337.html

你可能感兴趣的:(netcore)