1. Setting File
Position: conf/httpd.conf
2. Seting Example
2-1
----------------------------- https://www.itread01.com/content/1546777631.html
Apache2.2升級到Apache2.4後httpd.conf的配置差別總結。
1、Listen設定的差別
設定監聽埠需指定IP
如Listen 88
需要改成
Listen 192.168.0.1:88
2、日誌紀錄設定的差別
RewriteLogLevel 改為 logLevel
LOGLEVEL設定第一個值是針對整個Apache的預設等級,後面對指定的模組修改此模組的日誌記錄等級
3、需載入更多的模組
開啟Gzip在apache2.4中需額外載入mod_filter
開啟SSL在apache2.4中需額外載入mod_socache_shmcb
4、許可權設定的差別
Apache2.2用Order Deny / Allow的方式,2.4用Require
apache2.2:
Order deny,allow
Deny from all
apache2.4:
Require local
此處比較常用的有如下幾種:
Require all denied
Require all granted
Require host domain
Require ip 192.168.1.1
Require local
要注意的是:如果在htaccess檔案中有設定的也要相應修改
5、Namevirtualhost 2.4中已經被刪除
1、Listen設定的差別
設定監聽埠需指定IP
如Listen 88
需要改成
Listen 192.168.0.1:88
2、日誌紀錄設定的差別
RewriteLogLevel 改為 logLevel
LOGLEVEL設定第一個值是針對整個Apache的預設等級,後面對指定的模組修改此模組的日誌記錄等級
3、需載入更多的模組
開啟Gzip在apache2.4中需額外載入mod_filter
開啟SSL在apache2.4中需額外載入mod_socache_shmcb
4、許可權設定的差別
Apache2.2用Order Deny / Allow的方式,2.4用Require
apache2.2:
Order deny,allow
Deny from all
apache2.4:
Require local
此處比較常用的有如下幾種:
Require all denied
Require all granted
Require host domain
Require ip 192.168.1.1
Require local
要注意的是:如果在htaccess檔案中有設定的也要相應修改
5、Namevirtualhost 2.4中已經被刪除
2-2 Example
在 AWS EC2 裝好基本的 LAMP 環境之後,想設一下 Apache Virtual Host 設定
結果居然無法運作,查了一下才發現在 Apache 2.4.6 (或更之前) 有對這部份的設定做了一些調整
以下是簡易的筆記
1.
2. 原本的 http.conf 已經預設加上 IncludeOptional conf.d/*.conf
所以可以把 Virtual Host 的設定獨立成另一隻檔案,我習慣命名為 vhosts.conf,放在 /etc/httpd/conf.d/vhosts.conf
3. <VirtualHost> 的調整
由原本的
<VirtualHost sample.com>
DocumentRoot /var/www/www_sample
ServerName sample.com
CustomLog logs/access_log combined
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/www_sample">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
改為
<VirtualHost *:80>
DocumentRoot /var/www/www_sample
ServerName sample.com
CustomLog logs/access_log combined
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/www_sample">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
結果居然無法運作,查了一下才發現在 Apache 2.4.6 (或更之前) 有對這部份的設定做了一些調整
以下是簡易的筆記
1.
NameVirtualHost*:80
這行已經廢除,不用再寫了2. 原本的 http.conf 已經預設加上 IncludeOptional conf.d/*.conf
所以可以把 Virtual Host 的設定獨立成另一隻檔案,我習慣命名為 vhosts.conf,放在 /etc/httpd/conf.d/vhosts.conf
3. <VirtualHost> 的調整
由原本的
<VirtualHost sample.com>
DocumentRoot /var/www/www_sample
ServerName sample.com
CustomLog logs/access_log combined
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/www_sample">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
改為
<VirtualHost *:80>
DocumentRoot /var/www/www_sample
ServerName sample.com
CustomLog logs/access_log combined
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/www_sample">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
2-3 Remove welcome page
https://linuxconfig.org/how-to-disable-default-apache-welcome-page-on-redhat-linux
2-4 Default Parameters Ref https://kknews.cc/zh-tw/other/qorvg6b.html
配置文件位於:
[root@www ~]# vim /usr/local/http-2.4.23/conf/extra/httpd-default.conf
Timeout 5推薦5 這個是 apache接受請求或者發出相應的時間超過這個時間斷開KeepAlive On/Off KeepAlive指的是保持連接活躍,換一句話說,如果將KeepAlive設置為On,那麼來自同一客戶端的請求就不 需要再一次連接,避免每次請求都要新建一個連接而加重伺服器的負擔。一般情況下,圖片較多的網站應該把 KeepAlive設為On。
原文網址:https://kknews.cc/other/qorvg6b.html
2-5 Virtual host ref ref
在 Apache 上設定 VirtualHost 是牙齒掉下來然後又腐化掉的問題,但這問題又久久才會處理一次,剛不小心出了一點小問題,於是稍微記錄一下提醒自己。
設定 VirtualHost 目的是使用同一個伺服器架設多個網站,當使用者以不同網域名稱連到該主機時, web server 會依據不同的目的網頁需求,回應不同的網頁內容
2-6 https://httpd.apache.org/docs/2.4/mod/core.html#directory
Office Document
2-7 2.4 New document
Core Enhancements
- Run-time Loadable MPMs
- Multiple MPMs can now be built as loadable modules at compile time. The MPM of choice can be configured at run time via
LoadModule
directive. - Event MPM
- The Event MPM is no longer experimental but is now fully supported.
- Asynchronous support
- Better support for asynchronous read/write for supporting MPMs and platforms.
- Per-module and per-directory LogLevel configuration
- The
LogLevel
can now be configured per module and per directory. New levelstrace1
totrace8
have been added above thedebug
log level. - Per-request configuration sections
<If>
,<ElseIf>
, and<Else>
sections can be used to set the configuration based on per-request criteria.- General-purpose expression parser
- A new expression parser allows to specify complex conditions using a common syntax in directives like
SetEnvIfExpr
,RewriteCond
,Header
,<If>
, and others. - KeepAliveTimeout in milliseconds
- It is now possible to specify
KeepAliveTimeout
in milliseconds. - NameVirtualHost directive
- No longer needed and is now deprecated.
- Override Configuration
- The new
AllowOverrideList
directive allows more fine grained control which directives are allowed in.htaccess
files. - Config file variables
- It is now possible to
Define
variables in the configuration, allowing a clearer representation if the same value is used at many places in the configuration. - Reduced memory usage
- Despite many new features, 2.4.x tends to use less memory than 2.2.x
2-8 Remove Index browser index
https://www.itread01.com/content/1549475658.html
more clarn
https://www.tekfansworld.com/how-to-disable-apache-2-4-directory-browsing-on-ubuntu-16-04.html
2-9 Simple apach4 manipuate
http://igt.com.tw/5/linset/www1.htm
2-10 Scl apache 4
http://igofun.net/wordpress/2017/12/28/%E3%80%90centos-6%E3%80%91%E9%80%8F%E9%81%8E-scl-%E5%B0%87-apachehttpd-%E5%8D%87%E7%B4%9A%E5%88%B0-2-4-%E7%89%88/
2-9 Simple apach4 manipuate
http://igt.com.tw/5/linset/www1.htm
2-10 Scl apache 4
http://igofun.net/wordpress/2017/12/28/%E3%80%90centos-6%E3%80%91%E9%80%8F%E9%81%8E-scl-%E5%B0%87-apachehttpd-%E5%8D%87%E7%B4%9A%E5%88%B0-2-4-%E7%89%88/
2-11 Vshot 2
https://dywang.csie.cyut.edu.tw/dywang/rhce7/node78.html
2-12 apache management
https://blog.xuite.net/towns/hc/80213406-Apache%E5%AE%89%E8%A3%9D%E3%80%81%E8%A8%AD%E5%AE%9A%E8%88%87%E7%AE%A1%E7%90%862-13
https://dotblogs.com.tw/maplenote/2012/07/20/apache24_httpd_conf
沒有留言:
張貼留言