apache 服务器 CentOS 中的访问权限

Access permission in apache server CentOS

我安装了虚拟机CentOS 6.6。我还安装了 Apache,PHP,MySQL 和 yum

我将文档根目录从 /var/www/html 更改为 /www 所以我编辑了 /etc/httpd/httpd.conf 并更改了这两行:

DocumentRoot "/var/www/html"

<Directory "/var/www/html"> 

我重启了apache就没问题了

我尝试打开 http://192.168.199.90/phpinfo.php 时出现问题。 我得到了:

Forbidden You don't have permission to access /phpinfo.php on this server.

我尝试在 /etc/selinux/conf 中禁用 SElinux 并将 enforcing 更改为 disabled

我也试过这个:chcon -v -R --type=httpd_sys_content_t /www/

当我写 ls -laZ /www 时,我有:

drw-rw-rw-. www  www  unconfined_u:object_r:httpd_sys_content_t:s0 .
dr-xr-xr-x. root root system_u:object_r:root_t:s0      ..
-rwxrwxrwx. root root unconfined_u:object_r:httpd_sys_content_t:s0 phpinfo.php
drw-rw-rw-. www  www  unconfined_u:object_r:httpd_sys_content_t:s0 sites

编辑 httpd.conf 文件,该文件位于 /etc/httpd/conf/httpd.conf 中。添加以下代码。

<Directory "/var/www/html">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>

尝试:

chown -R apache:apache /www

chown -R www-data:www-data /www

顺便说一句,从不 禁用您的 SElinux

谢谢大家,我重新收藏了,

我更改了 SElinux 的当前模式 从 enforcingpermissive 通过在终端中写入 :

setenforce 0

所以当我写

getenforce 我得到 Permissive

我也做了 chmod 755 -Rf /www

;)