LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1413|回复: 7

apache2的localhost 访问不了 但是下面的php脚本可以访问...?

[复制链接]
发表于 2008-3-29 15:05:29 | 显示全部楼层 |阅读模式
情况是
输入 http://localhost 或者是http://localhost/try_linux
网页显示:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403

但是输入:http://localhost/try_linux/upload.php
可以正常访问网页内容

还有个问题,在php脚本里为localhost目录新建文件夹,有时成功,有时失败...这是什么情况。。我把这个目录的属主都改成wwwrun后也没有效果。

各位大侠赐教啊。
发表于 2008-3-29 15:08:48 | 显示全部楼层
在目录定义语句里面是不是没加Indexes.
Please,贴出来配置文件看看,这个好办。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-29 15:31:30 | 显示全部楼层
好! 我的httpd.conf是分开包含的,这个是default-server.conf ,先贴出来,大侠需要设么信息我继续贴...
#
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
#

DocumentRoot "/mnt/3/pdf/PHP/experience"

#
# Configure the DocumentRoot
#
<Directory "/mnt/3/pdf/PHP/experience">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs-2.2/mod/core.html#options
    # for more information.
    Options None
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride None
    # Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
</Directory>

# Aliases: aliases can be added as needed (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/srv/www/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
</Directory>

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
    # Note that the name of the user directory ("public_html") cannot simply be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
    UserDir public_html
    # The actual configuration of the directory is in
    # /etc/apache2/mod_userdir.conf.
    Include /etc/apache2/mod_userdir.conf
    # You can, however, change the ~ if you find it awkward, by mapping e.g.
    # http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/
    #AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
</IfModule>


# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf

# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?conf
回复 支持 反对

使用道具 举报

发表于 2008-3-29 15:39:21 | 显示全部楼层
不好意思,我问题不清晰
1. 你在http://localhost/try_linux/下 ... ndex.html/index.php
2. 你的php是不是有独立的配置文件,你修改过了吗?(这个可能不重要)
3. 你想要浏览http://localhost/try_linux/下面的文件吗?
如果是的话,将这个Options None改成Options Indexes


DocumentRoot "/mnt/3/pdf/PHP/experience"

#
# Configure the DocumentRoot
#
<Directory "/mnt/3/pdf/PHP/experience">
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.2/mod/core.html#options
# for more information.
Options None
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride None
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
</Directory>
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-29 15:47:53 | 显示全部楼层
哈哈,刚参照windows下的配置文件改过来,果然是这个问题,谢谢大侠!
还有...为什么用mkdir函数创建目录,浏览器提示
Warning: mkdir(): Permission denied in /mnt/3/pdf/PHP/experience/try_linux/kaooooo.php on line 2

间接调用脚本创建也不行......
可能不该在这个版子问,还是麻烦大侠帮帮忙...
回复 支持 反对

使用道具 举报

发表于 2008-3-29 15:53:31 | 显示全部楼层
Post by jiayi198821;1832478
哈哈,刚参照windows下的配置文件改过来,果然是这个问题,谢谢大侠!
还有...为什么用mkdir函数创建目录,浏览器提示
Warning: mkdir(): Permission denied in /mnt/3/pdf/PHP/experience/try_linux/kaooooo.php on line 2

间接调用脚本创建也不行......
可能不该在这个版子问,还是麻烦大侠帮帮忙...


把kaooooo.php贴来看看,上传文件的代码有很多的。还有要注意你是靠后台程序去创建目录的,所以程序进程的owner要有权限才行。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-29 16:01:31 | 显示全部楼层
真是厉害啊!我发现php进程号是30,于是找到用户为wwwrun
我把目录创建到wwwrun的家目录里就成功了!
大侠厉害!再次感谢。
回复 支持 反对

使用道具 举报

发表于 2008-3-29 16:17:19 | 显示全部楼层
Post by jiayi198821;1832490
真是厉害啊!我发现php进程号是30,于是找到用户为wwwrun
我把目录创建到wwwrun的家目录里就成功了!
大侠厉害!再次感谢。


太客气了,互相学习!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表