Apache2.4.6 添加虛擬主機


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后重啟即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM