以前自己對nginx還不熟悉的時候,對Apache2.2.x的相關配置還是比較熟悉的,然而隔了幾年再用回Apache,主流的版本已經變成2.4.x,習慣地套用以前在2.2.x下的成功案例的配置,結果發現報錯了。因為偷懶,在開發機器上就使用了XAMPP,沒注意Apache的具體版本,然后按照以前的經驗配置了虛擬主機,結果報錯,“you don't have permission to access / on this server”。
於是認認真真學習了兩個版本之間的差異,在此記錄其中一個常見的問題。
簡單對比,2.2.x常見配置格式如下
<VirtualHost *:80>
DocumentRoot
"D:/www/Apache24/htdocs"
ServerName localhost
<Directory D:/www/Apache24/htdocs>
DirectoryIndex index.html index.php
Order Deny,Allow
Allow
from
all
</Directory>
</VirtualHost>
但是這樣的配置在2.4.x下是不行的,應該將設置改成如下:
<VirtualHost *:80>
DocumentRoot "D:/www/sphinx/api"
ServerName www.mysphinx.com
<Directory "D:/www/sphinx/api">
Options FollowSymLinks Indexes
Require all granted
</Directory>
</VirtualHost>
這樣就算大功告成了。
我很懶,具體看如下原文。PS:為什么推酷會比博客園更容易被搜索到?