本文介绍了Ubuntu的/ Apache2的/禁止/允许误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Ubuntu 11.10安装灯

I have Ubuntu 11.10 with Lamp installed

有是我无法从我的web目录的/ var / www的

There is some files that i can't access to from my web directory "/var/www"


我得到一个错误:

http://localhost/banner/banner.htmlI am getting an error :

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

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

I can access /var/www/index.php normally as i can browse /var/www/banner normally too from my browser

这是小和平:

    a1a4a@A1A4a:~$ 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

    a1a4a@A1A4a:~$ 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 webmaster@localhost

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中设置为默认值...

My "nano /etc/apache2/apache2.conf" is set as default ...

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

How can i make all my /var/www files (folders and sub-folders and files ) accessible from my browser as if i was on a windows machine using Wamp ...

P.S:我将举办一个Windows机器我使用Ubuntu的网站上的只是编码

P.S: I will host the website on a Windows machine i am using ubuntu just for coding.

推荐答案

运行Apache的守护进程,在Ubuntu这就是WWW的数据用户(如大多数基于Debian的系统),需要为文件至少读权限。
但是当你只发布所有者和组已经阅读权利。

the user running the apache deamon, on ubuntu thats www-data (like in most debian based systems), needs at least read permissions for the files.But as you posted only owner root and group root has read rights.

其实所有者 RW​​ 研究

所以实际运行的网络服务器(WWW的数据)用户下降到其他用户的权限,这也没有。

So the user actually running the webserver (www-data) falls to the others permissions, which have none.

要么做一个搭配chmod -R O + R /无功/网络/旗帜/ * CHOWN -R www数据的/ var / WWW /旗帜来解决这个问题。

Either do a chmod -R o+r /var/www/banner/* or a chown -R www-data /var/www/banner to fix that.

这篇关于Ubuntu的/ Apache2的/禁止/允许误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 15:51