- nginx配置
server {
listen 80;
server_name 192.169.2.110;
root /www/root;
index index.php index.html;
location \ {
}
location ~ \.php$ {
root /www/root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-
用户配置
nginx启动用户为默认nginx用户,php-fpm启动用户修改为nginx保持一致 -
问题描述
配置均没问题的情况下
访问html文件都显示403
访问php文件显示This account is currently not available.
如果修改root目录为nginx默认目录则正常访问,所以推测是权限问题
目录权限基本都检查过N遍了,搜索后发现还又SELinux这个东西
SELinux介绍参考 https://blog.csdn.net/weixin_41078837/article/details/80571065 -
解决办法
- 关闭selinx
SELinux默认的工作模式是enforcing,我们可以将其修改为 permissive或者是disabled
修改为vim /etc/selinux/config
SELINUX=disabled
- 修改root目录的上下文信息
-R为递归
–reference 参照目录或文件,这里参照默认的html目录chcon -R --reference=/usr/share/nginx/html /www/root