Centos 7 中部署ASP.NET Core网站问题记录

学习阶段,参考大神 Ants 的博客“将ASP.NET Core应用程序部署至生产环境中(CentOS7)” 完成练习,在此表示非常感谢。

在这个过程中,还是遇到了一些问题,也记录下来以备忘。

一、 把Nginx加入SELinux白名单时的问题

在配置nginx对ASP.NET Core应用的转发时,涉及到SELinux策略配置,要把Nginx加入SELinux白名单,原文列出了如下命令:

    yum install policycoreutils-python

    sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx

    sudo semodule -i mynginx.pp

但我在非root用户下执行中间那句命令时,提示权限不够:
sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx

二、配置supervisor时的问题

配置完 supervisord.conf后,执行“supervisorctl reload”命令报错:

[root@d-centos7 nginx]# supervisorctl reload
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224

折腾了好久都解决不了,网上有说是配置里没指定user导致的,我还以为是supervisord.conf文件中的[supervisord]一节中要指定user,如下

[supervisord]
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
user=root                 ; default is current user, required if root
不过后来发现好像不是这里的问题,只要先不管这个问题,继续把应用配置即 [program:WebApplication1]配置好,应该就没有问题了。

全都配置好之后,发现有遇到了如下问题:

[root@d-centos7 conf.d]# supervisord -c /etc/supervisord.conf
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/bin/supervisord -h

这个问题,执行一下以下命令就解决了(可能是supervisord之前已经启动了):

[root@d-centos7 etc]# unlink /tmp/supervisor.sock

之后就正常了:

[root@d-centos7 etc]# supervisord -c /etc/supervisord.conf
[root@d-centos7 etc]# ps -ef |grep Web
root     25794 25790  2 22:31 ?        00:00:00 dotnet WebApp1.dll
root     25812 20065  0 22:31 pts/2    00:00:00 grep --color=auto Web




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Centos7发布说明 环境说明: 服务器系统:CentOS 7.2.1511 相关工具:Xshel、Xftp 服务器软件软件:.netcore、nginx、supervisor 准备好发布的程序 安装.NET Core SDK for CentOS7 打开网址:https://www.microsoft.com/net/core#linuxcentos 复制如下命令,单步执行: sudo yum install libunwind libicu curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019 sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet sudo ln -s /opt/dotnet/dotnet /usr/local/bin 输入 dotnet –info 来查看是否安装成功 配置Nginx 下载安装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 来启动nginx systemctl enable nginx 来设置nginx的开机启动(linux宕机、重启会自动运行nginx不需要连上去输入命令)。 配置防火墙 命令:firewall-cmd --zone=public --add-port=80/tcp --permanent(开放80端口) 命令:systemctl restart firewalld(重启防火墙以使配置即时生效) 测试nginx是否可以访问。 配置nginx对ASP.NET Core应用的转发 修改 /etc/nginx/conf.d/default.conf 文件,将文件内容替换为: server { listen 80; 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; } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值