ngxin 操作遇到的问题

本文介绍了Nginx出现bind()权限拒绝及403 forbidden错误的几种常见原因与解决方法,包括更改监听端口、调整文件权限和禁用SELinux等方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、nginx: [emerg] bind() to 0.0.0.0:80 failed (13: permission denied)

回答:
the socket API bind() to a port less than 1024, such as 80 as your title mentioned, need root access.
here is “Bind to ports less than 1024 without root access”
and another easier way is to run nginx as root.
解决方案:
修改端口为8080

2、解决Nginx出现403 forbidden (13: Permission denied)报错的三种办法

1)、缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件。

server {  
  listen       80;  
  server_name  localhost;  
  index  index.php index.html;  
  root  /data/www/;
}

如果在/data/www/下面没有index.php,index.html的时候,直接文件,会报403 forbidden。

2)、权限问题,如果nginx没有web目录的操作权限,也会出现403错误。
解决办法:修改web目录的读写权限,或者是把nginx的启动用户改成目录的所属用户,重启Nginx即可解决

chmod -R 777 /data
chmod -R 777 /data/www/

3) 、SELinux设置为开启状态(enabled)的原因。
3.1、查看当前selinux的状态。

/usr/sbin/sestatus

这里写图片描述
3.2、将SELINUX=enforcing 修改为 SELINUX=disabled 状态。

vi /etc/selinux/config

#SELINUX=enforcing
SELINUX=disabled

这里写图片描述
3.3、重启生效。reboot。
reboot
我这里出现错误的问题就是在第三步设置SELinux的问题上,折腾我好长时间。




参考地址 :
https://stackoverflow.com/questions/18480201/ubuntu-nginx-emerg-bind-to-0-0-0-080-failed-13-permission-denied

http://www.shuchengxian.com/article/658.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值