当'root'改变时,NGINX投掷'403 Forbidden'

时间:2017-11-23 01:13:19

标签: nginx virtualhost centos7

已经安装了新的centos7.4。尚未安装PHP或mySQL。只安装了NGINX。

'/ etc / nginx / nginx.conf'文件不受影响。

'/ etc / nginx / conf.d / default.conf'是:

server {
    listen       80;
    server_name public_IP private_IP;

    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

}

一切正常...... enter image description here

但是当我将配置更改为...

...
root /var/www/html;
...

它抛出错误: enter image description here

我已经命令:

sudo chmod -R 755 /var/www
sudo chown -R nginx:nginx /var/wwww

但不起作用。

1 个答案:

答案 0 :(得分:0)

如果你尝试了所有方法都没有成功,这个方法可以帮到你:

检查状态 SELinux

sestatus

如果启用:

# getenforce

# setenforce Permissive

并结束

sudo systemctl restart nginx