iLexN
3/7/2014 - 2:28 AM

Apache 2.2 升級到 2.4 的 Conf 調整修復

Apache 2.2 升級到 2.4 的 Conf 調整修復

http://www.hksilicon.com/kb/articles/409729/Apache-2224Conf

Debian jessie 將 Apache 改成 2.4 的版本, 然後就全部爛掉了~ 設定檔需要做大幅度的修改, 做作筆記.

apache2-mpm-event - transitional event MPM package for apache2
apache2-mpm-itk - transitional itk MPM package for apache2
apache2-mpm-prefork - transitional prefork MPM package for apache2
apache2-mpm-worker - transitional worker MPM package for apache2
Apache 2.2 升級到 2.4 的 Conf 調整修復
參考網頁

Upgrading to 2.4 from 2.2 - Apache HTTP Server
Overview of new features in Apache HTTP Server 2.4 - Apache HTTP Server
prefork - Apache HTTP Server
worker - Apache HTTP Server
event - Apache HTTP Server
Authentication and Authorization - Apache HTTP Server
Module Index - Apache HTTP Server
由  Debian wheezy => testing, 就會遇到 apache 2.2 升級到 2.4, 於是就出現下述錯誤訊息:

403 Forbidden
authz_core:error] [pid 6719] [client 122.96.59.104:57926] AH01630: client denied by server configuration
[Sun Nov 24 01:56:51.624289 2013] [authz_core:error] [pid 7250] [client 192.168.1.191:59434] AH01630: client denied by server configuration: /var/wwww/index.php

下述是 Apache 2.2 VS Apache 2.4 的設定檔有哪些變更差異

Deny All
2.2 configuration:
Order deny,allow
Deny from all
2.4 configuration:
Require all denied
Allow All
2.2 configuration:
Order allow,deny
Allow from all
2.4 configuration:
Require all granted
Allow Host
2.2 configuration:
Order Deny,Allow
Deny from all
Allow from example.org
2.4 configuration:
Require host example.org
Directory 用 Require all granted

Options FollowSymLinks
AllowOverride None
Require all granted

FilesMatch 維持用 Order

SetHandler application/x-httpd-php-source
Order Deny,Allow
Allow from all

找出有哪些需要設定需要修改:

cd /etc/apache2/sites-enabled/
grep -i deny *
grep -i "allow " *
grep -i "allow " * | grep -v '#'
哪邊有放 www 的, 就會需要打開 directory


Options FollowSymLinks
AllowOverride None
Require all granted

# 對整個開啟的話, 就跟 2.2 版一樣意思了.
Options FollowSymLinks
AllowOverride None
Require all granted

另外, 目錄裏面沒有放 index.html 而出現的 403 錯誤, 如下:

[Sun Nov 24 02:18:51.160249 2013] [autoindex:error] [pid 10541] [client 192.168.1.191:59786] AH01276: Cannot serve directory /var/www/css/: No matching DirectoryIndex (index.html,index.php,slideshow.xul,index.xul) found, and server-generated directory index forbidden by Options directive, referer: http://example.com/

加上下述:


Options FollowSymLinks Indexes
Require all granted

PHP 出現的 Warning

PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the +date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone +identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/www/bin/a.php on line +11

上述設定 timezone 即可.

PHP 遇到另外的修改會有下述:

apt-get install php5-json # json 需要另外安裝
php5-curl 裏面的預設參數, 都要改2
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  1);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
相關網頁
apache2 - How do I select which Apache MPM to use? - Server Fault
[Apache] Apache 從 2.2 換至 2.4 httpd.conf 的調整筆記 (windows 環境)
Apache Prefork、Worker和Event三種MPM分析 - 蟲師 - 博客園
笑遍世界 » Apache查看和更改正在使用的MPM(prefork, worker, event)