我有CentOS 6.1服务器,我在上面安装了apache 2.2.15。现在当我尝试从IE(http:///(= centos ip))从另一台PC(Windows 7)访问它时,我得到“你没有权限访问/在这台服务器上”。错误。我甚至在“var / www / html”上创建了内容为“”的phpinfo.php文件,当我尝试在IE中使用“http://*/phpinfo.php”访问它时,我找不到错误。我该怎么办?我对directiry的httpd.conf是这样的:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
编辑httpd.conf文件,该文件位于/etc/httpd/conf/httpd.conf
中。添加以下代码。
<Directory "/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
<Directory "/home/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
行后没有。 555(在我的情况下)。检查文件权限并重新启动服务器。
service httpd restart
现在,它会工作。仍然你面临同样的问题,在seLinux
中禁用/etc/selinux/config
更改SELINUX=disabled
并重新启动服务器,如上所述并尝试。
希望这可以帮助
尝试编辑httpd.conf
<Directory "/usr/local/www/apache24/cgi-bin">
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
在/etc/httpd/conf/httpd.conf中设置所需的全部内容
检查apache conf中/ var / www / html和ALLOW指令的文件权限
确保Web服务器可以读取所有文件,并且allow指令就像
<Directory "/var/www/html">
Order allow,deny
Allow from all
</Directory>
如果您可以看到文件,那么请考虑将该指令排序为更具限制性
使用以下命令在允许模式下设置SELinux:
setenforce 0;
拳头检查apache是否正在运行。 service httpd restart
重启
CentOS 6附带SELinux激活,因此,要么通过编辑/etc/sysconfig/selinux
设置SELINUX=disabled
来更改策略或禁用它。然后重启
然后在本地(从centos)检查apache是否正常工作。
尝试使用以下内容:chmod + rx / home / *
在根目录中创建index.html
或index.php
文件(在您的情况下 - /var/www/html
,如@jabaldonedo所述)
右键单击您的www文件夹,然后单击属性。导航到权限并将所有内容更改为读取和写入,然后单击“将权限应用于附带的文件”,您就完成了!也许为时已晚,但这肯定会帮助其他人
检查httpd.conf中的apache用户和组设置。它应默认为AMI / RedHat上的apache或Debian上的www-data。
grep '^Group\|^User' /etc/httpd/conf/httpd.conf
然后将apache用户添加到站点根目录的组设置中。
sudo usermod -a -G <your-site-root-dir-group> apache
如果你在许可模式下设置SELinux(命令setenforce 0
)并且它工作(对我有用),那么你可以运行restorecon(sudo restorecon -Rv /var/www/html/
),它永久地为Apache目录中的文件设置正确的上下文,因为setenforce是暂时的。 Apache的上下文是httpd_sys_content_t
,您可以验证它运行命令ls -Z /var/www/html/
,输出类似于:
-rwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 index.html
如果文件没有正确的上下文,则显示如下内容:
drwxr-xr-x. root root unconfined_u:object_r:user_home_t:s0 tests
希望它可以帮到你。
PD:对不起我的英语