• [原创]Debian10 安装配置ASP.NET Core+Nginx+Supervisor (2020.01.8更新)


    序言


     此教程安装的都是最新版本的。

     

     

    一键安装


     有了这个神器,下面的教程就不用做了!只需运行几行代码,直接打开浏览器就可以访问!

    cd /home/
    wget https://files.cnblogs.com/files/project/install.sh
    chmod 777 install.sh
    ./install.sh

     

     

    准备工作


    1. 更新系统

    没啥,就他喵想用个最新的。

    apt update && apt upgrade

     

    2. 创建目录

    创建目录,分别用来放配置文件和网站。

    mkdir /web/

     

     

    一、ASP.NET Core


    官方网站:https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-package-manager-debian10

    1. 注册Microsoft密钥和订阅源

    wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
    sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
    wget -q https://packages.microsoft.com/config/debian/10/prod.list
    sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
    sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
    sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

    2. 安装.NET Core SDK

    sudo apt-get update
    sudo apt-get install apt-transport-https
    sudo apt-get update
    sudo apt-get install dotnet-sdk-3.1

    3. 利用.NET Core SDK创建一个web实例

    创建 Web 应用项目

    cd /web/
    dotnet new webapp -o app

    二、Supervisor


    官方网站:http://www.supervisord.org/

     

    1. 安装Supervisor

    apt install -y supervisor

     

    2. 编辑supervisord.conf

    vim /etc/supervisor/supervisord.conf

     

    3. 新建配置文件

    将下面配置文件存到/etc/supervisor/conf.d/app.conf

    [program:app]
    command=dotnet run      ;要执行的命令
    directory=/web/app/     ;命令执行的目录
    autostart=true          ;是否自动启动
    autorestart=true        ;是否自动重启
    stderr_logfile=/var/log/webapp.err.log ;标准错误日志
    stdout_logfile=/var/log/webapp.out.log ;标准输出日志

    4. 重新启动

    supervisorctl shutdown
    supervisord -c /etc/supervisor/supervisord.conf

    四、Nginx


    官方网站:http://nginx.org/

    1. 安装nginx

    apt install -y nginx

     

    2. 编辑nginx.conf

    vim /etc/nginx/nginx.conf

     

    3. 修改如下

    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
    
        keepalive_timeout  65;
    
        gzip  on;
    
        server {
            listen       80;
            server_name  localhost;
    
            location / {
                proxy_pass https://localhost:5001;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_cache_bypass $http_upgrade;
            }
        }
    }

    4. 重新加载

    nginx -s reload

     

     

    五、效果预览


     

     

     

    、常用命令


     nginx

    # nginx             //启动nginx
    # nginx -s reload   //重启nginx
    # nginx -s stop     //关闭nginx

     

     supervisor

    supervisord
    supervisorctl status    //查看所有任务状态
    supervisorctl shutdown  //关闭所有任务
    supervisorctl start|stop|restart all          //控制所有进程
    supervisorctl start|stop|restart program_name //控制目标进程 

     

  • 相关阅读:
    python2的比较函数,cmp
    快速排序
    如果a,b,c为自然数,a+b+c=1000,a方+b方=c方,求出abc可能的组合(python实现)
    python之join
    python之functools partial
    Python 3 iter函数用法简述
    python线程之condition
    python 线程 event
    getattr getattribute setattr hasattr delattr
    Properties类
  • 原文地址:https://www.cnblogs.com/project/p/6942593.html
Copyright © 2020-2023  润新知