码迷,mamicode.com
首页 > Web开发 > 详细

.Net Core2.0 + Nginx + CentOS 部署

时间:2017-09-26 19:17:50      阅读:393      评论:0      收藏:0      [点我收藏+]

标签:emd   asp   .com   迁移   lib   rod   zip   systemd   stdout   

准备把项目往Linux上迁移,整个流程跑了一下,也遇到无数个坑。。。以下为亲测并修改后的完整流程。。。


安装ZIP

yum install -y unzip zip

 

Putty:WINDOWS上传文件到LINUX

pscp e:/1.tar.gz root@118.190.143.191:/root/fanrong/

 

安装.net core 2.0 依赖的组件

yum install deltarpm epel-release unzip libunwind gettext libcurl-devel openssl-devel zlib libicu-devel

 

安装.net core 2.0

sudo dnf install libunwind libicu
curl -sSL -o dotnet.tar.gz https://aka.ms/dotnet-sdk-2.0.0-linux-x64
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin
dotnet --help

 

安装nginx

yum install nginx

 

启动nginx

systemctl start nginx

 

设置nginx的开机启动(linux宕机、重启会自动运行nginx不需要连上去输入命令)

systemctl enable nginx

 

修改配置,监听5000端口:路径为:/etc/nginx/nginx.conf,修改如下:

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;
}

 



安装守护服务(Supervisor)

yum install python-setuptools
easy_install supervisor

 

配置Supervisor

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

 

需要修改/etc/supervisor/supervisord.conf文件:
最底部的[include]修改为:

[include]
files = /etc/supervisor/confg.d/*.conf

 

创建文件

vi /etc/supervisor/conf.d/test1.conf

 

内容如下:

[program:WebApplicationTest1]
command=dotnet WebApplicationTest1.dll
directory=/root/PublishOutput
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
startsecs=1
stderr_logfile=/var/log/CManage.err.log
stdout_logfile=/var/log/CManage.out.log

 


然后需要把supervisord重新加载:

supervisord -c /etc/supervisor/supervisord.conf

 

执行

nginx -s reload

 

查看进程

ps -ef

 


如果想要supervisord开机自启动

新建一个“supervisord.service”文件

vim /usr/lib/systemd/system/supervisord.service

 

内容如下

# dservice for systemd (CentOS 7.0+)
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

 


执行命令:

systemctl enable supervisord 设定开机启动

 

执行命令:

systemctl is-enabled supervisord #来验证是否为开机启动

 

.Net Core2.0 + Nginx + CentOS 部署

标签:emd   asp   .com   迁移   lib   rod   zip   systemd   stdout   

原文地址:http://www.cnblogs.com/wenrouyeshicuo/p/7598071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!