apache 2.2 和2.4 目录权限访问设置的区别
在apache 2.4上 order deny,allow不好使,调了半天没有效果,困扰很久,最后发现原来是版本的问题。
2.4配置访问权限如下:
#####允许所有,拒绝个别ip(类似黑名单)#####
<RequireAll>
Require all granted
Require not ip 192.168.8.106 192.168.8.105
</RequireAll>
上面等同于apache2.2的:
order deny,allow
deny from 192.168.8.106 192.168.8.105
或
order allow,deny
allow from all
deny from 192.168.8.106 192.168.8.105
#####拒绝所有,允许个别ip(类似白名单)。#####
Require ip 192.168.8.107 192.168.8.105
上面等同于apache2.2的:
order allow,deny
allow from 192.168.8.106 192.168.8.105
或
order deny,allow
deny from all
allow from 192.168.8.106 192.168.8.105
附上本人apache2.4版本httpd-vhosts.conf目录配置
#document root
<VirtualHost *:80>
DocumentRoot "E:/wamp/www"
ServerName localhost
ServerAlias localhost
</VirtualHost>
################vhosts################
<VirtualHost *:80>
DocumentRoot "E:/wamp/www/hope"
ServerName 192.168.8.107
ServerAlias 192.168.8.107
<Directory "E:/wamp/www/hope">
Options Indexes FollowSymLinks
AllowOverride All
#<RequireAll>
require all granted
#require not ip 192.168.8.106 192.168.8.105
#</RequireAll>
#Require ip 192.168.8.107 192.168.8.105
</Directory>
</VirtualHost>
另外:包含vhosts.conf配置文件后,个人习惯删除httpd.conf中的目录描述部分,添加到vhosts.conf中,方便管理。
浏览器输入ip,默认访问的是第一条host配置