apache documentroot指向htcdoc之外提示403错误的解决方法

apache documentroot指向htcdoc之外提示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

分享到 :
相关推荐

视频服务器(视频服务器的主要作用)

监控系统作为安全重要保障,在城市或农村可以说是无处不在,可见,监控系统对生活的影响是...

softlayer服务器购买教程(美国服务器免费ip地址)

大家好,今天来介绍softlayer服务器购买教程(美国服务器租用100m)的问题,...

怎么评估机柜服务器功耗和重量(怎么评估机柜服务器功耗和重量的关系)

评定服务器机柜网络服务器的功率是大数据中心室内设计师的较大挑戰。沒有絕對的参考答案。...

做游戏用美国服务器有哪些优势(做游戏用美国服务器有哪些优势呢)

做游戏用美国服务器的优势有:1。美国服务器不用备案。节省了复杂的备案时间。能立即上线...

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注