2011-12-19 96 views
3

我的Ubuntu 11.10与灯安装的Ubuntu/Apache2的/禁止/允许误差

有,我无法从我的web目录 “的/ var/www” 的

http://localhost/banner/banner.html 我访问某些文件出现错误:

禁止您无权访问此服务器上的/banner/banner.html。 的Apache/2.2.20(Ubuntu的)服务器在本地主机端口80

我可以访问/var/www/index.php正常,因为我可以从我的浏览器浏览的/ var/WWW /旗帜常太

这是一个小的和平:

[email protected]:~$ ls -l /var/www 
    total 7088 
    -rwxrwxrwx 1 root root  916 2011-11-25 20:49 access-controlled.php 
    -rw-r--r-- 1 root root 22163 2011-12-16 22:28 account_info.php 
    -rw-r--r-- 1 root root 22126 2011-12-16 22:27 account_info.php~ 
    -rw-r--r-- 1 root root 16585 2011-12-16 21:32 acount_info.php 
    -rw-r--r-- 1 root root  0 2011-12-16 21:28 acount_info.php~ 
    drwxrwxrwx 5 root root 4096 2011-12-09 23:03 banner 
    drwxrwxrwx 2 root root 4096 2011-12-09 23:03 css 

而且

[email protected]:~$ ls -l /var/www/banner 
    total 20 
    -rw--w---- 1 root root 2564 2011-11-25 20:51 banner.html 
    drwx-w---- 4 root root 4096 2011-12-09 23:03 examples 
    drwx-w---- 2 root root 4096 2011-12-09 23:03 lib 
    drwx-w---- 4 root root 4096 2011-12-09 23:03 skins 
    -rw--w---- 1 root root 1431 2011-11-25 20:51 style.css 

这是我的配置:

<VirtualHost *:80> 
ServerAdmin [email protected] 

DocumentRoot /var/www 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory> 
<Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride None 
    Order allow,deny 
    allow from all 
</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 ${APACHE_LOG_DIR}/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel warn 

CustomLog ${APACHE_LOG_DIR}/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> 

</VirtualHost> 

我的“纳米/etc/apache2/apache2.conf中”设置为默认值...

我怎样才能让我的所有的/ var/WWW文件(文件夹和子文件夹和文件)从我的浏览器访问,就好像我在使用Wamp的Windows计算机上一样...

PS:我将在Windows机器上托管网站,我使用的只是用于编码的ubuntu。

回答

0

可能是您的banner.html权限有问题 - apache的用户甚至没有权限读取它。

3

运行apache deamon的用户,在ubuntu上这就是www-data(就像大多数基于debian的系统一样),至少需要读取这些文件的权限。 但是,因为您只发布店主root,并且组root已具有读取权限。

其实所有者rootrwrootr

因此,实际运行网络服务器(www-data)的用户会落入其他权限,而这些权限都没有。

要么做一个chmod -R o+r /var/www/banner/*chown -R www-data /var/www/banner来解决这个问题。

1

我总是忘记,虽然子目录和文件需要读取权限,但子目录也需要执行权限。

chmod a+x banner 

这往往会拿出当我在保存网页“网页,全部”与Chrome或Firefox格式,然后我试图为它服务在本地主机,建立了实体模型时我经常这样做客户端。

相关问题