本节内容:
只要把主目录指到其它地方,则会提示权限不够的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换成自己的目录即可。
2,启用vhosts
启用vhosts,则不用做上述修改,因为VirtualHost可以单独配置这个节的属性,所以在VirtualHost这个节里配置,则更为方便。
下面的配置中,把网站放在:/var/vhosts/www.jb200.com下。
例如:
/usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
<Directory "/var/vhosts/www.jb200.com" >
#Deny from all
Allow from all
</Directory>
DocumentRoot "/var/vhosts/www.jb200.com"
ServerName www.jb200.com
</VirtualHost>
如果把Deny from all的注释去掉,那么服务器就会拒绝所有访问(和刚开始把主目录移动到htdocs外而没做任何配置修改时一样)
小结:
记得加上默认主页,否则也会提示访问错误。
例如: