设备:阿里云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]\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' sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.1.

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

最新文章

  1. bs4 python解析html
  2. [git]Git log 输出格式化(转载)
  3. GitHub和SourceTree入门教程——(转载),希望能帮到有需要的人
  4. sublime-text3插件安装
  5. 如何使用robots不让百度和google收录
  6. Jsp页面获取项目名称
  7. 15. 使用Apache Curator管理ZooKeeper
  8. ACM讲座心得
  9. Github速度慢的解决方法
  10. map映射巧用 A-B Problems
  11. position:absolute在IE8浏览器下无法显示正确位置
  12. asp.net状态保持
  13. ZSTU4274 约素 2017-03-22 17:11 66人阅读 评论(0) 收藏
  14. win10下安装mysql-5.7.25-winx64
  15. PHP服务端支持跨域
  16. 在sql server数据库可以插入在回车的数据
  17. 【C++】各种成员变量
  18. SPI编程1:用户空间的读写操作
  19. Collections练习之对字符串先折半,再取最长的一个
  20. 22 nginx配置与集群

热门文章

  1. 在CentOS实现mysql数据库的自动备份
  2. PHP------------正则表达式应用——实例应用
  3. Avito Cool Challenge 2018 E. Missing Numbers 【枚举】
  4. sqlserver事务怎么开启 怎么提交 怎么回滚
  5. webConfig中System.Web 和 System.WebServer节点读取
  6. HDU 1016 Prime Ring Problem(素数环问题)
  7. win7下添加库文件出现“file is not regcognized”问题
  8. mysql数据库迁移到oracle数据库后 如何删除相同的数据
  9. 学习笔记 - 2sat
  10. Plugin 'InnoDB' registration as a STORAGE ENGINE failed