zoukankan      html  css  js  c++  java
  • 在生产环境中部署asp.net core应用

    设备:阿里云ECS云主机

    操作系统:centos 7

    操作步骤:

    1 安装.net core sdk:

    # 添加dotnet product feed
    
    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    sudo sh -c 'echo -e "[packages-microsoft-com-prod]
    name=packages-microsoft-com-prod 
    baseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
    
    sudo yum install libunwind libicu 
    sudo yum install dotnet-sdk-2.1.4

    2 安装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

    3 安装supervisor:

    yum install supervisor
    
    mkdir /etc/supervisor
    
    echo_supervisord_conf > /etc/supervisor/supervisord.conf

    4  配置supervisor:

    mkdir /etc/supervisor
    
    echo_supervisord_conf > /etc/supervisor/supervisord.conf

    修改supervisord.conf文件,在文件尾部增加:

    [include]
    files=conf.d/*.conf

    在/etc/supervisor/conf.d,创建一个 WebApplication1.conf文件,内容大致如下

    [program:WebApplication1]
    command=dotnet WebApplication1.dll ; 运行程序的命令
    directory=/home/wwwroot/WebApplication1/ ; 命令执行的目录
    autorestart=true ; 程序意外退出是否自动重启
    stderr_logfile=/var/log/WebApplication1.err.log ; 错误日志文件
    stdout_logfile=/var/log/WebApplication1.out.log ; 输出日志文件
    environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量
    user=root ; 进程执行的用户身份
    stopsignal=INT

    5 配置nginx:

    修改 /etc/nginx/conf.d/default.conf 文件。

    将文件内容替换为

    server {
        listen 8080;
        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;
        }
    }

    6 启动程序:

    ps -ef | grep supervisord
    
    # 如果提示Error: Another program is already listening on a port that one of our HTTP servers is configured to use. 
    kill -s SIGTERM ****
    
    # 运行supervisord,查看是否生效
    
    supervisord -c /etc/supervisor/supervisord.conf
    
    ps -ef | grep WebApplication1
  • 相关阅读:
    在DNN模块开发中使用jQuery
    在MSBuild.exe中使用条件编译(Conditional Compile)
    ASP.NET SQL 注入免费解决方案
    html+css做圆角表格
    [ASP]sitemap地图生成代码
    刺穿MYIE|24小时同一ip弹一次|无须body加载|精简代码
    用ASPJPEG组件制作图片的缩略图和加水印
    16个经典面试问题回答思路[求职者必看]
    一个26岁IT男人写在辞职后
    搜弧IT频道的幻灯片切换的特效源代码
  • 原文地址:https://www.cnblogs.com/dadream/p/8361607.html
Copyright © 2011-2022 走看看