Apache 从 2.2 换至 2.4 httpd.conf 的修改 (windows 环境) 不指定

jed , 2017-2-8 23:56 , 服务器技术 , 评论(0) , 阅读(51180) , Via 本站原创 | |
http://httpd.apache.org/docs/2.4/upgrading.html

http://httpd.apache.org/docs/2.4/new_features_2_4.html



/*2012.12.25 補充*/

apache 2.4.3 版有對 window 版的 ssl bug 做修正 ,bug 說明 http://www.apachelounge.com/viewtopic.php?p=22306

這個 bug 簡而言之就是會讓 443 的頁面連線掛點...



1. 權限設定方式變更

原本使用 Order Deny / Allow 的方式,改用 Require

官方範例:

2.2 configuration:

Order deny,allow
Deny from all
在 2.4 需要改成

2.4 configuration:

Require all denied
比較常用到的有以下幾種

Require all denied

Require all granted

Require host xxx.com

Require ip 192.168.1 192.168.2

Require local

注意 : 若有設定在 .htaccess 中的也要修改

詳細指令說明 : http://httpd.apache.org/docs/2.4/mod/mod_authz_core.html#require



2. 設定 Log 紀錄方式變更

RewriteLogLevel 指令 改為 logLevel

LogLevel 設定第一個值是針對整個 Apache 設的預設等級,後方可以對指定的模組修改此模組的 Log 記錄等級

範例:

LogLevel warn rewrite: warn

詳細指令說明 請查看: http://httpd.apache.org/docs/2.4/mod/core.html#loglevel



3. Namevirtualhost 被移除

雖然我查官方文件是還有 NameVirtualHost 指令,但是執行時會出現錯誤。

官方文件也寫了這個指令目前是無作用的,因此刪掉此設定。

詳細說明: http://httpd.apache.org/docs/2.4/mod/core.html#namevirtualhost



4. 其他要多載入的模組

使用網站壓縮除了開啟 mod_deflate 外 ,在 Apache 2.4 中還需要多開 mod_filter

使用SSL憑證除了開啟 mod_ssl 外 ,在 Apache 2.4 中還需要多開 mod_socache_shmcb



5. 在 windows 環境建議的設定

EnableSendfile Off

EnableMMAP Off



另外,當 Log 有出現 AcceptEx failed 相關錯誤時,建議調整以下設定

AcceptFilter http none

#AcceptFilter https none 這行 apache 2.4.1 設了就不能連443了,所以我沒設定,在 apache 2.4.3 版可正常運作

bug 修正相關文件: http://www.apachelounge.com/viewtopic.php?p=22306



指令說明 http://httpd.apache.org/docs/2.4/mod/core.html#acceptfilter

備註:  Win32DisableAcceptEx 指令在 apache2.4 被 AcceptFilter None 取代

相關參考文章:

http://www.neo.com.tw/archives/000223

http://www.iteye.com/news/24881

http://www.apachelounge.com/viewtopic.php?t=4450



6. Listen 的設定調整

以 443 為例,不可以只設定 Listen 443

會出現以下錯誤

(OS 10048)一次只能用一個通訊端位址(通訊協定/網路位址/連接埠)。  : AH00072: make_sock: could not bind to address [::]:443

(OS 10048)一次只能用一個通訊端位址(通訊協定/網路位址/連接埠)。  : AH00072: make_sock: could not bind to address 0.0.0.0:443

AH00451: no listening sockets available, shutting down

AH00015: Unable to open logs

因此需指定監聽的 IP ,可設定多個

例如:

Listen 192.168.2.1:443

Listen 127.0.0.1:443



其他異常BUG :

某天突然心血來潮測試了一下可不可以開啟 .htaccess 的檔案,很驚恐的居然可以開啟  冏

原本 httpd.conf 預設不可開啟 .ht* 的設定失效!

<Files ".ht*">

    Require all denied

</Files>

測試的結果,httpd.conf 裡的 完全失效 !

不確定跟 設定有沒有關係 ( 其實我跟 httpd.conf 沒這麼熟,我都是被刀抵著脖子的 =..=a )

經過半天的折磨,最後發現改用 LocationMatch 設定還勉強行得通

因為我沒有用到 htpasswd ,所以比較不怕 .ht* 的檔案被開啟 ....所以就先用這種跛腳的方式解決了.....

例如:

<LocationMatch "\.svn">

     Require all denied

</LocationMatch>

注意: 子階層的 LocationMatch 設定,指令要設在母階層的行數之下,不然會被覆蓋

且不可以對 " .ht* " 設定!!

因為 Server 就無法讀取 .ht* 的資料...當然裡面的設定就不能跑了



另外就是 .htaccess 中, 可能會失效

而且 .htaccess 裡無法設定 LocationMatch .........(嘆氣)

在我的環境中,Server 2008 的 .htaccess 有生效,

但是在 Win7 環境中,放在第二層資料夾的 .htaccess 有生效 ,若第三層資料夾才放  .htaccess 就會失效

Tags:
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]