Nginx - bind() to 0.0.0.0:xxxx failed (13: Permission denied)

Nginx 启动异常记录

运行下面的指令,启动nginx。

[root@localhost /]# sudo systemctl start nginx

预期是nginx启动成功,但是出现了下面这个问题

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

启动失败随之去查看nginx的日志

[root@localhost /]# tail -f -n 200 /var/log/nginx/error.log 
2020/04/17 15:11:05 [emerg] 13475#13475: bind() to 0.0.0.0:8070 failed (13: Permission denied)

端口绑定失败,权限不足。经查询发现是开启了selinux导致的,关闭即可。

处理命令

先检查selinux是否开启了,输入以下命令,返回enforcing 那就是开启。 disabled 或 permissive是关闭。

[root@localhost /]# getenforce
Enforcing

临时关闭方式,0对应关闭,1是开启。

[root@localhost /]# setenforce 0

永久关闭方式,修改配置文件,最后执行source命令,使配置立即生效

[root@localhost /]# vim /etc/selinux/config

SELINUX=disabled

[root@localhost /]# source /etc/selinux/config

 至此再次启动Nginx即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值