步骤
aspnetcore程序端口号5001,实际外部端口号8001,相当于把8001收到的请求转发给5001.
把发布出来的文件全部丢掉 /var/www/JuXiangTou 里面去。可以用scp命令或者winscp客户端
centos 7.x
aspnet core 的运行环境,不需要装sdk,一般sdk里面是包含runtime的
nginx,一个反向代理服务,把过来的http请求转发给实际的aspnetcore处理
?
1
2
3
4
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
装好nginx要配置端口之类的。
nginx.conf是默认的配置文件,基本不用动。
?
1
2
cd conf.d
vim kestrel-juxiangtou.conf
下面主要就是两个端口号的需要改一下,其他都可以不用改动。
?
1
2
3
4
5
6
7
8
9
10
11
server {
listen 8001;
location / {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
}
保存退出
验证一下配置,然后重新载入
?
1
2
sudo nginx -t
sudo nginx -s reload
防火墙firewall-cmd。不一定装过,要看环境。
?
1
2
3
4
systemctl status firewalld
firewall-cmd –zone=public –add-port=8001/tcp –permanent
firewall-cmd –reload
systemctl restart firewalld.service
建一个服务,用于维护dotnetcore的程序进程
?
1
2
cd /etc/systemd/system
vim kestrel-juxiangtou.service
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=JuXiangTou
[Service]
WorkingDirectory=/var/www/JuXiangTou
ExecStart=/usr/bin/dotnet /var/www/JuXiangTou/Site.WebApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=JuXiangTou
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
保存退出
?
1
systemctl restart kestrel-juxiangtou.service
重启一下服务。
配置一下阿里云的网络安全组里面的端口
参考资料
http://www.projectcodify.com/hosting-aspnet-core-on-linux-using-nginx
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://www.cnblogs.com/sheldon-lou/p/9277085.html
声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。