【问题标题】:Access permission in apache server CentOSapache服务器CentOS中的访问权限
【发布时间】:2015-07-13 23:37:43
【问题描述】:

我已经安装了虚拟机 CentOS 6.6。我还使用yum 安装了 Apache、PHP、MySQL。

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

DocumentRoot "/var/www/html"

<Directory "/var/www/html"> 

我重启了apache,没问题。

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

禁止 您无权访问此服务器上的 /phpinfo.php。

我尝试在 /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

【问题讨论】:

    标签: php apache centos6


    【解决方案1】:

    谢谢大家,我很喜欢它,

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

    setenforce 0

    所以当我写的时候

    getenforce 我得到Permissive

    我也做了 chmod 755 -Rf /www

    ;)

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 谢谢你的回答,但你的意思还是一样的问题 ,因为我想把它改成 /www。
      • 是的,请检查您的 .httpd.conf 文件以获取目录权限。
      • 同样的错误,ps:我使用客户端机器访问服务器
      • 你可以试试AllowOverride All
      • 谢谢@Hardy Mathew,我重置了它并将 SElinux 当前模式从 Enforcing 更改为 Permissive
      【解决方案3】:

      试试:

      chown -R apache:apache /www
      

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

      顺便说一句,永远不要禁用你的SElinux

      【讨论】:

      • 谢谢@sky 我重置它并将 SElinux 当前模式从 Enforcing 更改为 Permissive
      猜你喜欢
      • 1970-01-01
      • 2020-07-19
      • 2013-11-18
      • 1970-01-01
      • 2013-06-14
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      相关资源
      最近更新 更多