標籤:錯誤記錄檔 文章 pac 許可權 orb 主機 win 虛擬 match
改用Apache2.4一段時間了,一直沒發現它和Apache2.2的有什麼區別,一些基本配置都是差不多,直到前幾天配置虛擬機器主機是才發現了一些小小的不同
一直以來我都是在htdocs目錄下配置虛擬機器主機的,大體上使用的方法如下:
01.<VirtualHost *:80> 02. DocumentRoot "D:/www/Apache24/htdocs"03. ServerName localhost 04. <Directory D:/www/Apache24/htdocs> 05. DirectoryIndex index.html index.php 06. Order Deny,Allow 07. Allow from all 08. </Directory> 09.</VirtualHost>
但是最近我想在目錄htdocs之外配置虛擬機器主機,還是按照上面的老套路來配置,結果出現的403錯誤:
1.<STRONG>Forbidden</STRONG> 2.You don‘t have permission to access / on this server.
瞬間沒了頭緒,這是在Apache2.2所沒有的出現過的情況啊,然後試著將虛擬機器主機的根目錄改成htdocs目錄之下,也就是
1.DocumentRoot "D:/www/Apache24/htdocs/test"
發現網站又能正常運行了,反覆試了多次都是同一的結果。然後我就想到底是哪個地方出現了問題,這個問題困擾了我幾天,百度找了無數答案,大部分都是說目錄的許可權有錯誤,需要修改許可權,或者是selinux設定的問題,可是我啟動並執行環境是windows,所以這些情況也被排除在外;有些說是需要設定Allow from all ,也沒有效果。
通過查看錯誤記錄檔,發現有那麼一行:
1.AH01630: client denied by server configuration: D:/www/
但是我的Order指令設定都是正確的,這樣我鬱悶了一段時間,無意中發現了一篇文章描述Apache2.4與Apache2.2之間的一些指令的差異,剛好解決了我的問題,
其中的一些指令已經無效,如:
1.Order Deny,Allow<BR>Deny from all<BR>Allow from al
取而代之的是:
1.Deny from all 2.變成 3.Require all denied 4. 5.Allow from all 6.變成 7.Require all granted
於是我將虛擬機器設定為:
1.<VirtualHost *:80> 2. DocumentRoot "D:/www/sphinx/api"3. ServerName www.mysphinx.com 4. <Directory "D:/www/sphinx/api"> 5. DirectoryIndex index.html index.php 6. Require all granted 7. </Directory> 8.</VirtualHost>
發現還是提示403錯誤,只不過這次的錯誤記錄檔的錯誤變成:
1.AH01276: Cannot serve directory D:/www/sphinx/api/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
這是因為裡面的根目錄裡面沒有index.html 或者 index.php,我們可以添加index.html檔案或者將設定改成如下:
1.<VirtualHost *:80> 2. DocumentRoot "D:/www/sphinx/api"3. ServerName www.mysphinx.com 4. <Directory "D:/www/sphinx/api"> 5. Options FollowSymLinks Indexes 6. Require all granted 7. </Directory> 8.</VirtualHost>
這樣就算大功告成了,不過我敢肯定Apache2.4與Apache2.2的區別不止於此,只是我還沒有發現而已,期待進一步的發現。
Apache2.4.x與Apache2.2.x的一些區別