我觉得这是一个相当简单的解决方法,并且在search时遇到了类似的问题,但无法用这些解决scheme修复它。 基本上问题是我无法访问我的networking服务器上的任何子目录。 去localhost提出的指数罚款。 但是去localhost / test会出现403 Forbidden错误。
我正在运行CentOS。 我已经尝试编辑/etc/httpd/conf/httpd.conf文件,但没有运气。 DocumentRoot位于/ var / www / html。 目前我有:
<Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
我已经尝试添加以下内容:
<Directory "/var/www/html/test"> Order allow,deny Allow from all </Directory>
但它仍然给我403禁止的错误。
您不需要特别允许访问在httpd.conf中已经configuration的目录下面的目录
由于/ var / www / htmlconfiguration了“AllowOverride None”,所以问题不是由于.htaccess文件改变了访问权限。
唯一剩下的原因是对文件和目录的权限不允许webserver uid从这个目录读取。 他们是什么,他们应该是什么取决于你的安全模型。 但作为一个快速解决scheme,你可以尝试:
# chmod a+rx /var/www/html/test # chmod a+r /var/www/html/*
如果这解决了这个问题,那么请花些时间将文件的所有权和权限修改为更合适的内容。
通常我build议先看一下http error_log来查看确切的问题。
使用默认configuration,您应该能够访问workshop-5.4目录:
<Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
如果仍然无法访问目录,则所有内容都指向目录权限,那么我build议尝试:
chown -R apache.apache /var/www/html # Assuming apache as default User chmod -R 755 /var/www/html # Making sure all users can read and execute
在单独的terminal上运行以下命令:
apachectl configtest && apachectl restart tail -f /etc/httpd/logs/error_log # Assuming default error_log location
尝试添加一个简单的html文件,如(example.html):
<html> <head><body>It works!</body></head> </html>
最后,重新加载页面,尝试加载example.html并查看tail命令的输出。
注释这些<Directory>指令,并简单地设置DocumentRoot /var/www/html和chown -R apache:apache /var/www/html并重新启动httpd 。
应该使用<Directory>指令将指令组应用到特定的文件系统目录(即更改权限),所以通常要在<VirtualHost>使用它。