昨天給公司配置了apache-2.4.9的版本,今天他們要求把虛擬主機配置起好放網站程序,在修改apache-2.4.9的配置文件中,我發現了2.4.x跟以前的2.2.x里面的很多配置都不一樣了,比如配置這個虛擬主機都有一些不同,按照以前的配置方法,會報下面的錯誤:
AH01630: client denied by server configuration: /usr/local/apache/htdocs/recx/
先給大家看看我按照apache-2.2.x配置虛擬機的內容:
NameVirtualHost 192.168.10.81:80
代碼如下:
- <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">
- //開源代碼Vevb.com
- 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.
上面幾個是我目前知道不一樣的地方,大家如果有發現其他的,請分享出來.
新聞熱點
疑難解答