apache 2.4.x与2.2.x版本很多配置信息的写法不同,如果2.4.x版本按2.2.x版本的写法书写,则会出现标题中的错误;
apache-2.2.x配置虚拟机的大致写法如下:
<span style="color: rgb(68, 68, 68); font-family: 'Times New Roman'; font-size: 14px; line-height: 26px;">NameVirtualHost 192.168.10.81:80</span>
<VirtualHost 192.168.10.81:80>
ServerAdmin rocdk890@gmail.com
directoryIndex index.html index.php index.htm index.shtml login.php
ServerName 192.168.10.81
DocumentRoot /var/www/vhosts/wwwroot
<Directory "/var/www/vhosts/wwwroot">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
apache-2.4.x配置虚拟机的大致写法如下:
<VirtualHost 192.168.10.81:80>
ServerAdmin rocdk890@gmail.com
directoryIndex index.html index.php index.htm index.shtml login.php
ServerName 192.168.10.81
DocumentRoot /var/www/vhosts/wwwroot
<Directory "/var/www/vhosts/wwwroot">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
可以看到apache-2.4.x把NameVirtualHost给取消,现在配置虚拟主机不需要再配置NameVirtualHost了.
删除了 Order deny,allow 和 Order allow,deny
把 Deny from all 替换成了 Require all denied
把Allow from all 替换成了 Require all granted
然后还把 Allow from 192.168.10.21 这样的语句给替换成了 Require host 192.168.10.21
转自:http://www.111cn.net/phper/apache/60401.htm