美文网首页
.NetCoreMVC发布到linux+nginx

.NetCoreMVC发布到linux+nginx

作者: INSO8 | 来源:发表于2019-12-01 00:59 被阅读0次

    sudo :代表超级命令,以防有些命令普通用户执行不了
    1、更新yum

    sudo yum update
    

    2、下载DotnetCore SDK

    sudo yum install dotnet-sdk-3.0
    
    //测试是否安装成功
    dotnet -version 
    
    //打包.NetCoreMVC程序命令
    dotnet publish -c release
    
    //运行.NetCoreMVC程序命令
    dotnet 项目名.dll
    

    3、安装nginx

    sudo yum install nginx
    

    4.启动nginx

    systemctl start nginx
    //开机启动nginx
    systemctl enable nginx 
    

    5、开放80端口

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

    6、修改Nginx的配置:etc/nginx/conf.d/default.conf

    server {
      listen 80;
      server_name localhost;
      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 -t: 测试配制文件是否正确
    nginx -s reload 重新加载nginx配制文件,不用重启nginx
    

    相关文章

      网友评论

          本文标题:.NetCoreMVC发布到linux+nginx

          本文链接:https://www.haomeiwen.com/subject/xcnawctx.html