SELinux 对nginx访问目录的影响

centos新装的系统,用yum 安装的nginx 。

因用yum 安装的nginx 默认目录在/usr下面。

当SELinux开启时,将会禁止访问设置在其他路径下的地址。比如我设置server 中 root  /home/www/public

无论你将文件的权限设置为777 还是多少,日志中都会提示  :***  open() "/home/www/centre/public/index.html" failed (13: Permission denied), client:   ***   

页面显示 403 错误。

只有关闭了SELinux后,才能正常访问。

查看状态:

/usr/sbin/sestatus -v

临时修改状态命令:

setenforce [ Enforcing | Permissive | 1 | 0 ] // 1 开启, 0 关闭

永久关闭,需要设置文件/etc/sysconfig/selinux 并重启才能生效

猜你喜欢

转载自www.cnblogs.com/kofsony/p/11057898.html