Apache '您无权访问此服务器上的 xx' [英] Apache 'You don't have permission to access xx on this server'
问题描述
我正在使用 ubuntu 12.04 和 apache(两者都是新的),我想添加一个新的虚拟目录,所以我修改了文件 /etc/apache2/sites-available/default
,添加以下内容:
I am using ubuntu 12.04 and apache (new in both of them) and I want to add a new virtual directory so I modify the file /etc/apache2/sites-available/default
, adding the following:
Alias /docs/ "/home/kk/workspace/javascript/maplib/"
<Directory "/home/kk/workspace/javascript/maplib/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
</Directory>
然后我在浏览器中打开 url http://localhost/docs/
并收到以下消息:
Then I open the url http://localhost/docs/
in the browser and I get the following message:
You don't have permission to access /docs/ on this server.
那我觉得可能是文件/文件夹权限造成的.因此,我通过以下方式向所有用户添加了 read
权限:
Then I think it may be caused by the file/folder permission. So I add the read
permession to all users by:
sudo chmod a+r /home/kk/workspace/javascript/maplib/
然后我跑
ls -ld ~/workspace/javascript/maplib/
我得到了这个:
drwxr--r-- 14 kk kk 4096 Mar 11 08:36 /home/kk/workspace/javascript/maplib/
正如您所看到的,每个用户都拥有对目录的 read
访问权限,但没有任何变化(我也收到了 403
消息).
As you can see every user shold have the read
access to the directory, but nothing changed ( I also get the 403
message).
然后我尝试找到/var/www
的权限,我得到:
Then I try to find the permission of /var/www
and I get:
drwxr-xr-x 2 root root 4096 Mar 8 15:33 /var/www
似乎只是给文件夹添加了execute
权限,但我认为这不是问题.
It seems that it just add the execute
permission to the folder, but I do not think this is the problem.
这是怎么回事?
顺便说一句,为什么 apache 用两个不同的 url 识别 /docs
和 /docs/
?由于我将通过 localhost/docs
获得 404
?
BTW, why does apache identify /docs
and /docs/
with two different url? Since I will get 404
by localhost/docs
?
推荐答案
在你的 Apache 安装中,访问是使用 etc/apache2/envars 控制的,并在 etc/apache2/apache2.conf 中实现
In your Apache installation access is controlled using etc/apache2/envars and implemented in etc/apache2/apache2.conf
在/etc/apache2/apache2.conf 中,您会在文件的一半左右找到以下几行.
In /etc/apache2/apache2.conf you will find the following lines about half way down a the file.
#These need to be set in /etc/apache2/envars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
在/etc/apache2/envars 你会发现
In /etc/apache2/envars you will find
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
您希望网络服务器访问的目录必须在运行网络服务器的组中.我会说检查组权限并在必要时修复它们.如果您正确设置了这些,请返回并发布 Apache 访问日志.
The directories you want the webserver to access need to be in the group running the webserver. I would say to check the group permissions and fix them if necessary. If you have these set correctly come back and post the Apache access logs.
这篇关于Apache '您无权访问此服务器上的 xx'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!