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

时间:2018-07-24 15:38:46

标签: php apache centos7

我已经用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软件包。也许我需要其他包裹吗?

我在做什么错了?

编辑我:

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

enter image description here

为什么会出现此错误?

编辑II:

在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

2 个答案:

答案 0 :(得分:0)

该问题的解决方案是:

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

@Lou怎么说这是SELinux问题。

答案 1 :(得分:-1)

我不愿意完全禁用SELINUX。这是对我有用的方法:restorecon -R / var / www / html /