apache2.4 與 apache2.2 的虛擬主機配置寫法有所不同
apache2.2的寫法:
<VirtualHost *:80> ServerName domain.com DocumentRoot "/home/www" DirectoryIndex index.html index.php <Directory "/home/www"> Options -Indexes +FollowSymlinks AllowOverride All Order deny,allow Allow from all </Directory> </VirtualHost>
如果在2.4中使用以上寫法就會出現apache AH01630: client denied by server configuration異常。
apache2.4中的寫法為
<VirtualHost *:80> ServerName domain.com DocumentRoot "/home/www" DirectoryIndex index.html index.php <Directory "/home/www"> Options -Indexes +FollowSymlinks AllowOverride All Require all granted </Directory> </VirtualHost>
解決方法,apache2.4中需要將
Order deny,allow
Allow from all
Allow from host ip
改為
Require all granted
Require host ip
注:yum安裝的httpd,在/etc/httpd/conf.d/目錄下添加vhosts.conf后重啟即可。