1. 问题
forbidden (13: Permission denied)
Nginx报错日志error.log:
2019/11/05 16:37:44 [error] 4603#4603: *30 "/home/trunk/xxx/web/index.php" is forbidden (13: Permission denied), client: 192.168.1.186, server: xxxxx.hyper.com, request: "GET / HTTP/1.1", host: "xxxxx.hyper.com"
2.解决:网站查找方法
1、缺少文件索引
2、权限问题
3、SELinux状态
2.1.缺少文件索引
缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件,如果在/data/www/下面没有index.php,index.html的时候,直接文件,会报403 forbidden
server {
listen 80;
server_name localhost;
index index.html;
root /home/trunk/xxx/web/;
}
我的配置
location / {
root /home/trunk/xxx/web;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
经过检查配置没问题。
2.2.权限问题
权限问题,如果nginx没有web目录的操作权限,也会出现403错误
chmod -R 777 /xxx
chmod -R 777 /xxx/web/
设置后没有解决问题
2.3.SELinux状态(关闭SELinux)
临时关闭:setenforce 0 立即不用重启
永久关闭:(将SELINUX=enforcing 修改为 SELINUX=disabled 状态)
vim /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
重启reboot