CentOS + Apache:您无权访问此服务器上的/info.php

问题描述 投票:0回答:1

我已经安装了带有Apache Web Server和PHP的CentOS 7。但是当我尝试测试php时,我遇到了这个错误

enter image description here

info.php的用户和组是“apache”

enter image description here

我的文档根被定义为您可以看到:

enter image description here

如果我尝试使用http://localhost访问它是有效的,但当我尝试访问http://localhost/info.php然后它失败!

我已经安装了php和php-fpm包。也许我还需要其他套餐吗?

我究竟做错了什么?

编辑I:

在access_log文件中查找错误我发现此错误:

enter image description here

为什么我会收到此错误?

编辑二:

在error_log文件中查找我发现这是一个权限问题:

[Tue Jul 24 18:44:21.084670 2018] [mime_magic:error] [pid 4986] [client ::1:38162] AH01512: mod_mime_magic: can't read `/var/www/html/info.php'
    [Tue Jul 24 18:44:21.084848 2018] [core:error] [pid 4986] (13)Permission denied: [client ::1:38162] AH00132: file permissions deny server access: /var/www/html/info.php

但该文件属于“apache”用户和组... :(

enter image description here

编辑III:

enter image description here

php apache centos7
1个回答
0
投票

该问题的解决方案是:

sudo chcon -R -v -t httpd_sys_rw_content_t info.php

@Lou如何说这是一个SELinux问题。

© www.soinside.com 2019 - 2024. All rights reserved.