apache documentroot指向htcdoc之外提示403错误的解决方案
2010-04-19 19:49
387 查看
在windows和RH都碰到过,只要把主目录指到其他地方后就出现权限不够的403提示,郁闷了好久。
后来发现,原来又是Apache没配置 好,是apache的mod_authz_host模块在起控制作用。
1.如果不启用vhosts
只需修改 httpd.conf
默认Directory节如下,注意红色部分,表示目录/usr/local/apache/htdocs允许所有 主机访问
<Directory "/usr/local/apache/htdocs">
#
# 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 Indexes FollowSymLinks
#
# 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>
由于主目录被指到别的地方了,所以将蓝色部分/usr/local/apache/htdocs换成你新的主目录就OK了。
2.启用vhosts
启 用vhosts的话,你就可以不作上面的修改了,因为VirtualHost可以单独配置这个节的属性,所以我们在VirtualHost这个节里配置的 话就更方便了,下面的配置中,我把我的网站放在/var/vhosts/www.test.cn下。
/usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
<Directory "/var/vhosts/www.test.cn" >
#Deny from all
Allow from all
</Directory>
DocumentRoot "/var/vhosts/www.test.cn"
ServerName www.test.cn
</VirtualHost>
如果把Deny from all的注释去掉,那么服务器就会拒绝所有访问(和我们刚开始把主目录移动到htdocs外而没做任何配置修改时一样,哈哈)
补充一点:
如果你是写个index.php放在目录下测试,可要注意了,记得加上默认主页index.php
DirectoryIndex index.html index.php
后来发现,原来又是Apache没配置 好,是apache的mod_authz_host模块在起控制作用。
1.如果不启用vhosts
只需修改 httpd.conf
默认Directory节如下,注意红色部分,表示目录/usr/local/apache/htdocs允许所有 主机访问
<Directory "/usr/local/apache/htdocs">
#
# 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 Indexes FollowSymLinks
#
# 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>
由于主目录被指到别的地方了,所以将蓝色部分/usr/local/apache/htdocs换成你新的主目录就OK了。
2.启用vhosts
启 用vhosts的话,你就可以不作上面的修改了,因为VirtualHost可以单独配置这个节的属性,所以我们在VirtualHost这个节里配置的 话就更方便了,下面的配置中,我把我的网站放在/var/vhosts/www.test.cn下。
/usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
<Directory "/var/vhosts/www.test.cn" >
#Deny from all
Allow from all
</Directory>
DocumentRoot "/var/vhosts/www.test.cn"
ServerName www.test.cn
</VirtualHost>
如果把Deny from all的注释去掉,那么服务器就会拒绝所有访问(和我们刚开始把主目录移动到htdocs外而没做任何配置修改时一样,哈哈)
补充一点:
如果你是写个index.php放在目录下测试,可要注意了,记得加上默认主页index.php
DirectoryIndex index.html index.php
相关文章推荐
- apache提示DocumentRoot must be a directory
- Apache 在更改DocumentRoot,或新增虚拟目录之后出现403错误的解决方法汇总详解(Linux)
- Apache - "DocumentRoot must be a directory"的解决方案
- linux CentOs 权限导致的Apache - "DocumentRoot must be a directory"的解决方案
- MAC OS X Apache DocumentRoot 403 forbidden 原因 & 解决方案
- Apache修改DocumentRoot后访问页面出现403错误的解决办法
- Apache 在更改DocumentRoot,或新增虚拟目录之后出现403错误的解决方法汇总详解(Linux)
- linux CentOs 权限导致的Apache - "DocumentRoot must be a directory"的解决方案
- apache启动提示Document root must be a directory
- 彻底地/ 终于地, 解决 关于apache 权限的问题了:: 修改 DocumentRoot后的 403错误: have no permission to access / on this server
- Apache 在更改DocumentRoot,或新增虚拟目录之后出现403错误的解决方法汇总详解(Linux)
- apache提示DocumentRoot must be a directory
- Win7下mysql root账户登录提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)解决方案
- eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案
- 当root用户无密码,非超级权限用户时提示mysqladmin: Can't turn off logging; error: 'Access denied; you need the SUPER privilege for this op解决方案
- Linux更改Apache网站目录出错:Document root must be a directory解决
- 通过apache访问非documentroot下面的程序
- eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案
- Multiple DocumentRoot on Apache on Win7