准备把项目往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 libicucurl -sSL -o dotnet.tar.gz https://aka.ms/dotnet-sdk-2.0.0-linux-x64sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnetsudo ln -s /opt/dotnet/dotnet /usr/local/bindotnet --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-setuptoolseasy_install supervisor
配置Supervisor
mkdir /etc/supervisorecho_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.dlldirectory=/root/PublishOutputenvironment=ASPNETCORE_ENVIRONMENT=Productionuser=rootstopsignal=INTautostart=trueautorestart=truestartsecs=1stderr_logfile=/var/log/CManage.err.logstdout_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=forkingExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.confExecStop=/usr/bin/supervisorctl shutdownExecReload=/usr/bin/supervisorctl reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target
执行命令:
systemctl enable supervisord 设定开机启动
执行命令:
systemctl is-enabled supervisord #来验证是否为开机启动
.Net Core2.0 + Nginx + CentOS 部署
原文地址:http://www.cnblogs.com/wenrouyeshicuo/p/7598071.html