nginx填坑之路(1)Nginx 检测语法正常,启用报 [emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied)错误处理...

参考文档:Nginx 启动报 [emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied)错误处理

nginx 启动失败: 检测语法正常,启用端口报错:[emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied)错误处理

nginx启动报错详细日志
[root@localhost conf.d]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2022-08-01 22:24:46 KST; 2min 50s ago
  Process: 27391 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 27600 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 27598 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 27392 (code=exited, status=0/SUCCESS)

Aug 01 22:24:46 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
Aug 01 22:24:46 localhost.localdomain nginx[27600]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Aug 01 22:24:46 localhost.localdomain nginx[27600]: nginx: [emerg] bind() to 0.0.0.0:8885 (13: Permission denied) 《===报错信息
Aug 01 22:24:46 localhost.localdomain nginx[27600]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 01 22:24:46 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Aug 01 22:24:46 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Aug 01 22:24:46 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Aug 01 22:24:46 localhost.localdomain systemd[1]: nginx.service failed.
[root@localhost conf.d]# 
[root@localhost conf.d]# 
[root@localhost conf.d]# journalctl -xe
Aug 01 22:24:46 localhost.localdomain nginx[27600]: nginx: [emerg] bind() to 0.0.0.0:8885 failed (13: Permission denied) 《===报错信息
Aug 01 22:24:46 localhost.localdomain nginx[27600]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 01 22:24:46 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Aug 01 22:24:46 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has failed.
-- 
-- The result is failed.
Aug 01 22:24:46 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Aug 01 22:24:46 localhost.localdomain systemd[1]: nginx.service failed.
Aug 01 22:24:46 localhost.localdomain polkitd[620]: Unregistered Authentication Agent for unix-process:27592:10276196 (system bus name :1.223, object path /org/freedesktop/PolicyKit1/Authenti
Aug 01 22:27:13 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:13 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:14 localhost.localdomain kernel: SELinux:  8 users, 14 roles, 5051 types, 318 bools, 1 sens, 1024 cats
Aug 01 22:27:14 localhost.localdomain kernel: SELinux:  130 classes, 113338 rules
Aug 01 22:27:14 localhost.localdomain kernel: SELinux:  Converting 2343 SID table entries...
Aug 01 22:27:16 localhost.localdomain dbus[617]: [system] Reloaded configuration
Aug 01 22:27:20 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:20 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:20 localhost.localdomain kernel: SELinux:  8 users, 14 roles, 5051 types, 318 bools, 1 sens, 1024 cats
Aug 01 22:27:20 localhost.localdomain kernel: SELinux:  130 classes, 113338 rules
Aug 01 22:27:20 localhost.localdomain kernel: SELinux:  Converting 2343 SID table entries...
Aug 01 22:27:23 localhost.localdomain dbus[617]: [system] Reloaded configuration
Aug 01 22:27:26 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:26 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 113338 rules.
Aug 01 22:27:26 localhost.localdomain kernel: SELinux:  8 users, 14 roles, 5051 types, 318 bools, 1 sens, 1024 cats
Aug 01 22:27:26 localhost.localdomain kernel: SELinux:  130 classes, 113338 rules
Aug 01 22:27:26 localhost.localdomain kernel: SELinux:  Converting 2343 SID table entries...
Aug 01 22:27:29 localhost.localdomain dbus[617]: [system] Reloaded configuration

系统启动Nginx报错: [emerg] bind() to 0.0.0.0:XXXX failed (13: Permission denied)错误的处理方式,分为两种:

第一种:端口小于1024的情况:
[emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

原因是1024以下端口启动时需要root权限,所以sudo nginx即可。 或者 修改/etc/nginx/nginx.conf 配置文件将user nginx;改成 user root;

第二种:端口大于1024的情况:
[emerg] bind() to 0.0.0.0:8885 failed (13: Permission denied)

这种情况,需要如下操作:
1、查看http允许访问的端口:

semanage port -l | grep http_port_t
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988

2、将要启动的端口(8881)加入到如上端口列表中

semanage port -a -t http_port_t  -p tcp 8885
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值