CentOS + Apache:您无权访问此服务器上的/info.php
I have installed CentOS 7 with Apache Web Server and PHP. But when I try to test php I've got this error
The user and group of info.php are "apache"
My Document Root is defined like you can see:
If I try to access with http://localhost it works, but when I try to access with http://localhost/info.php then it fails!!!
I have installed php and php-fpm package. Maybe Would I need other packages?
What am I doing wrong?
Edit I:
Looking for an error in access_log file I have found this error:
Why I get this error?
Edit II:
Looking for in error_log file I have found that is a problem of permissions:
[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
But the file belongs to "apache" user and group ... :(
Edit III:
我已经安装了带有Apache Web Server和PHP的CentOS 7。 但是当我尝试测试php时,我遇到了这个错误 p>
用户和 info.php组是“apache” p>
我的文档根目录定义与您一样 可以看到: p>
如果我尝试使用 http:// localhost 它有效,但是当我尝试使用 http://localhost/info.php 然后失败!!! p>
我已经安装了php和php-fpm软件包。 我可能需要其他套餐吗? p>
我做错了什么? p>
编辑我: strong> p> \ n
在access_log文件中查找错误我发现此错误: p>
为什么我会收到此错误? p>
编辑II: strong> p>
在error_log文件中查找我发现 是权限问题: p>
但该文件属于“apache”用户和组 ... :( p>
nn [Tue Jul 24 18:44:21.084670 2018] [mime_magic:error] [pid 4986] [client :: 1:38162] AH01512: mod_mime_magic:无法读取`/var/www/html/info.php'
[Tue Jul 24 18:44:21.084848 2018] [core:error] [pid 4986](13)权限被拒绝:[client :: 1:38162] AH00132:文件权限拒绝服务器访问:/var/www/html/info.php
The solution to the problem is:
sudo chcon -R -v -t httpd_sys_rw_content_t info.php
How @Lou said it was a SELinux problem.