又一个(13)权限拒绝了Apache2服务器上的错误

我只是无法弄清楚。 我在Ubuntu 10.04 i386服务器上运行apache2。 每当我访问我的服务器(有一个IP地址,并连接到互联网与静态IP xxx.xxx.xxx.xxx),这不是问题)在浏览器, mysub.domain.edu (在这里重命名),我得到以下:

Forbidden You don't have permission to access /index.html on this server 

apache2错误日志证实了这一点:

 [Mon Apr 18 02:38:20 2011] [error] [client zzz.zzz.zzz.zzz] (13)Permission denied: access to / denied 

我会尽力在下面提供所有必要的信息:

1)/etc/apache2/httpd.conf的内容

 DirectoryIndex index.html index.php 

2)/ etc / apache2 / sites-available / default的内容

 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /home/myusername/htdocs <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/home/myusername/htdocs/"> Options Indexes FollowSymLinks MultiViews AllowOverride None order allow,deny allow from all DirectoryIndex index.html index.php Satisfy any </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ServerName mysub.domain.edu </VirtualHost> 

3)/ etc / apache2 / sites-enabled / 000-default的内容

 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /home/myusername/htdocs <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/home/myusername/htdocs/"> Options Indexes FollowSymLinks MultiViews AllowOverride None order allow,deny allow from all DirectoryIndex index.html index.php Satisfy any </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ServerName mysub.domain.edu </VirtualHost> 

4)ls -l的结果(当我用sudo -i做root的时候):

 root@myserver:/home/myusername# ls -l total 4 drwxr-xr-x 2 www-data root 4096 2011-04-18 03:04 htdocs 

5)ps auxwww | grep -i apache

 root@myserver:/home# ps auxwww | grep -i apache root 15121 0.0 0.4 5408 2544 ? Ss 16:55 0:00 /usr/sbin/apache2 -k start www-data 15122 0.0 0.3 5180 1760 ? S 16:55 0:00 /usr/sbin/apache2 -k start www-data 15123 0.0 0.5 227020 2788 ? Sl 16:55 0:00 /usr/sbin/apache2 -k start www-data 15124 0.0 0.5 227020 2864 ? Sl 16:55 0:00 /usr/sbin/apache2 -k start root 29133 0.0 0.1 3320 680 pts/0 R+ 16:58 0:00 grep --color=auto -i apache 

6)ls -al / home / myusername / htdocs /

 root@myserver:/# ls -al /home/myusername/htdocs/ total 20 drwxr-xr-x 2 www-data root 4096 2011-04-18 03:04 . drw-r--r-- 4 myusername myusername 4096 2011-04-18 02:13 .. -rw-r--r-- 1 root root 69 2011-04-18 02:14 index.html 

我目前没有在我的用户文件夹的web根(htdocs)文件夹中使用任何.htaccess文件。

我不知道什么是错,我一直在努力修理他超过12个小时,而我却无处可去。 如果你有什么build议,我全都是耳朵…

使你的/家庭/用户名和/家有755的权限

EDITL:我会添加到这里,所以更容易阅读

你发布了这个:

 drwxr-xr-x 2 www-data root 4096 2011-04-18 03:04 . drw-r--r-- 4 myusername myusername 4096 2011-04-18 02:13 .. 

正如你所看到的,/ home / myusername文件夹有rw,r,r。 您需要给该文件夹和/ home文件夹“x”

 chmod o+x /home chmod o+x /home/myusername 

(这更像是一个debuggingbuild议,因为我认为Pratik用+ x来回答这个问题)

你提到的错误是一个文件系统权限错误,所以除非你的apacheconfiguration文件redirect/别名到文件系统的某些受限制的地方,那么你的问题是在/ home / myusername / htdocs目录的权限,或索引.html文件。

为了看到你的apache用户被拒绝,运行以下命令;

 su -s /bin/bash apache 

然后尝试

 cd /home/myusername/htdocs 

我总是开始复制你的configuration到你的主目录和'apt-get purge apache2'。

然后重新安装它,并执行“diff -y oldfile newfile”来查看更改。 如果奇怪,它不是configuration更改,那么它是您的网站根目录的权限。

只需要几分钟,除非你有很多的虚拟主机。

注意有关权限的错误build议。 通常你不应该把755放在你的/ home / username目录下。

在httpd.conf文件中logging了正确的权限,我将在这里粘贴相关部分:

 # This usually means that ~userid (/home/username for the lay person) # must have permissions of 711 

在〜userid的注意711被推荐,请避免755为/ home / username(〜userid)!!!!!!!! ,

 #~userid/public_html must have permissions" # of 755" 

〜userid / public_html可以给755,但是如果你给你的〜userid文件夹755,你系统上的所有人将能够访问你的home文件夹并读取你的文件并在家里执行文件,用户系统。 711避免给出阅读访问权限等