Centos6 上的 Httpd 未列出目录内容

Centos6 上的 Httpd 未列出目录内容

我的 Centos6.4 服务器上有一个文件夹(不是传统的 /var/www/html 文件夹!)/Server/Websites/Default。只有一个文件 phpinfo.php(其中包含明显的代码)。http://localhost/Default/phpinfo.php在 Firefox 中运行,显示正确的 php 信息页面。当我访问http://localhost/Default/页面时,它会显示一个禁止访问的“您无权访问此服务器上的 /。”页面。我希望它列出目录内容。

在我的 /etc/httpd/conf/httpd.conf 文件中,我有(太长而无法显示,所以我粘贴了一些我认为重要的关键行):

DocumentRoot "/Server/Websites"
<Directory /Server/Websites>
    Options +Indexes Includes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

就 SELinux 而言,我也有# getsebool -a | grep httpd

allow_httpd_anon_write --> off
allow_httpd_mod_auth_ntlm_winbind --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> on
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_manage_ipa --> off
httpd_read_user_content --> off
httpd_run_stickshift --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_tmp_exec --> off
httpd_tty_comm --> on
httpd_unified --> on
httpd_use_cifs --> off
httpd_use_fusefs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off
httpd_use_openstack --> off
httpd_verify_dns --> off

# ls -lZ

drwxr-xr-x. root root unconfined_u:object_r:public_content_rw_t:s0 Websites

我在监督什么?

答案1

事实证明,您必须在 httpd 配置中明确说明选项 +Indexes。非常感谢大家的回答。

答案2

首先,验证目录 /Server/Websites/Default 的权限。您的 Apache 用户(在 RHEL/CentOS apache 中)是否有权限列出目录的内容(至少是该用户的 rx)?

其次,尝试验证 SELinux 是否负责。尝试仅使用以下方法暂时启用宽容模式:

setenforce 0

如果现在可以正常工作,则可能是目录/文件的上下文存在问题。使用以下命令重新启用强制模式:

setenforce 1

并使用以下方式递归地重新标记新的目录结构

chcon -R --reference=/var/www /Server/Websites

这有帮助吗?

相关内容