1、MPM可于運作時裝載;
2、Event MPM
3、異步讀寫
4、在每子產品及每目錄上指定日志級别;
5、每請求配置;<If>, <ElseIf>, <Else>;
6、增強的表達式分析器;
7、毫秒級的KeepAlive Timeout;
8、基于域名的虛拟主機不再需要NameVirtualHost指令;
9、降低了記憶體占用;
10、支援在配置檔案中使用自定義變量;
新增加的子產品:
mod_proxy_fcgi(可以提供fcgi代理)
mod_proxy_scgi(支援scgi協定)
mod_proxy_express
mod_remoteip(能夠強大的比對用戶端的IP位址)
mod_session(保持使用者會話)
mod_ratelimit(限制每個使用者的帶寬)
mod_request(請求子產品,對請求做強大的過濾)
等等;
一、準備階段
本機環境
1
2
3
4
5
<code>[root@bogon ~]</code><code># cat /etc/issue</code>
<code>CentOS release 6.5 (Final)</code>
<code>Kernel \r on an \m</code>
<code>[root@bogon ~]</code><code># uname -r</code>
<code>2.6.32-431.el6.x86_64</code>
預安裝軟體包
<code>[root@bogon run]</code><code># yum groupinstall -y "Server Platform Development"</code>
<code>[root@bogon run]</code><code># yum groupinstall -y "Development tools"</code>
<code>[root@bogon run]</code><code>#yum install -y pcre-7.8-6.el6.x86_64 pcre-devel-7.8-6.el6.x86_64</code>
二、下載下傳apr-1.5.0、apr-util-1.5.3、http2.4.9
<code>[root@bogon Downloads]</code><code>#wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.9.tar.bz2</code>
<code>[root@bogon Downloads]</code><code>#wget ftp://ftp.mirrorservice.org/sites/ftp.apache.org/apr/apr-util-1.5.3.tar.bz2</code>
<code>[root@bogon Downloads]</code><code>#wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.bz2</code>
三、編譯安裝軟體包
1、apr-1.5.0.tar.bz2
apr:apache portable run-time是apache運作時環境,為了能使apache運作在不同的平台上
并且能使用同樣的機制,是以apr能夠抹除不同系統的資料庫,讓apache運作環境的機制都一樣,
并且能讓apache的某些特性跨平台的使用。
<code>[root@bogon </code><code>local</code><code>]</code><code># tar xf apr-1.5.0.tar.bz2</code>
<code>[root@bogon </code><code>local</code><code>]</code><code>#cd apr-1.5.0</code>
<code>[root@bogon apr-1.5.0]</code><code># ./configure --prefix=/usr/local/apr</code>
<code>[root@bogon apr-1.5.0]</code><code>#make && make install</code>
2、apr-util-1.5.3.tar.bz2
<code>#tar xf apr-util-1.5.3.tar.bz2</code>
<code>#cd apr-util-1.5.3</code>
<code>#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr</code>
<code>#make && make install</code>
3、http2.4.9.tar.bz2
<code>#tar xf httpd-2.4.9.tar.bz2</code>
<code># cd httpd-2.4.9</code>
<code>#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event</code>
編譯參數說明:
--prefix=/usr/local/apache:指定安裝路徑
--sysconfdir=/etc/httpd24:指定配置檔案存放位置
--enable-so:允許運作時加載DSO子產品
--enable-ssl: 提供對安全套接字層(SSL)和傳輸層安全(TLS)協定實作高強度加密傳輸
--enable-cgi:提供對CGI腳本執行的支援
--enable-rewrite:支援重寫
--with-zlib:是支援zlib庫
--with-pcre:啟用正規表達式
--with-apr=/usr/local/apr:Apache可移植運作時(APR)是httpd源碼的一部分并會自動與httpd一起建立。如果你想使用一個已經存在的APR ,就必須在這裡指定apr-config腳本的路徑。
--with-apr-util=/usr/local/apr-util/:Apache可移植運作時工具包(APU)是httpd源碼的一部分并會自動與httpd一起建立。如果你想使用一個已經存在的APU ,就必須在這裡指定apu-config腳本的路徑。
--enable-modules=most:啟用大多數常用子產品。
--enable-mpms-shared=all:啟用MPM支援的所有模式。
--with-mpm=event:設定預設MPM為event。
四、參數設定
1、導出庫檔案
<code>[root@bogon apache]</code><code># ln -s /usr/local/apache/include/ /usr/include/httpd24</code>
2、輸出二進制程式
<code>#vim /etc/profile.d/http24.sh</code>
<code>export</code> <code>PATH=</code><code>/usr/local/apache/bin</code><code>:$PATH</code>
<code>#source /etc/profile.d/http24.sh</code>
3、導出man手冊
<code>#vim /etc/man.config</code>
<code>#MANPATH /usr/local/apache/man</code>
五、測試
<code># apachectl start</code>
<code># ss -tunl |grep ":80"</code>
<code>tcp LISTEN 0 128 :::80 :::*</code>
<code># curl 192.168.1.114</code>
<code><html><body><h1>It works!<</code><code>/h1</code><code>><</code><code>/body</code><code>><</code><code>/html</code><code>></code>
六、添加服務腳本
1、先關掉apache服務
<code>#apachectl stop</code>
2、修改httpd的主配置檔案,設定其Pid檔案的路徑,編輯/etc/httpd24/httpd.conf,添加如下行即可
<code># vim /etc/httpd24/httpd.conf</code>
<code>PidFile </code><code>"/var/run/httpd24.pid"</code>
3、修改服務腳本
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<code>#!/bin/bash</code>
<code>#</code>
<code># httpd Startup script for the Apache HTTP Server</code>
<code># chkconfig: - 85 15</code>
<code># description: The Apache HTTP Server is an efficient and extensible \</code>
<code># server implementing the current HTTP standards.</code>
<code># processname: httpd</code>
<code># config: /etc/httpd/conf/httpd.conf</code>
<code># config: /etc/sysconfig/httpd</code>
<code># pidfile: /var/run/httpd/httpd.pid</code>
<code>### BEGIN INIT INFO</code>
<code># Provides: httpd</code>
<code># Required-Start: $local_fs $remote_fs $network $named</code>
<code># Required-Stop: $local_fs $remote_fs $network</code>
<code># Should-Start: distcache</code>
<code># Short-Description: start and stop Apache HTTP Server</code>
<code># Description: The Apache HTTP Server is an extensible server</code>
<code># implementing the current HTTP standards.</code>
<code>### END INIT INFO</code>
<code># Source function library.</code>
<code>. </code><code>/etc/rc</code><code>.d</code><code>/init</code><code>.d</code><code>/functions</code>
<code>if</code> <code>[ -f </code><code>/etc/sysconfig/httpd</code> <code>]; </code><code>then</code>
<code> </code><code>. </code><code>/etc/sysconfig/httpd</code>
<code>fi</code>
<code># Start httpd in the C locale by default.</code>
<code>HTTPD_LANG=${HTTPD_LANG-</code><code>"C"</code><code>}</code>
<code># This will prevent initlog from swallowing up a pass-phrase prompt if</code>
<code># mod_ssl needs a pass-phrase from the user.</code>
<code>INITLOG_ARGS=</code><code>""</code>
<code># Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server</code>
<code># with the thread-based "worker" MPM; BE WARNED that some modules may not</code>
<code># work correctly with a thread-based MPM; notably PHP will refuse to start.</code>
<code># Path to the apachectl script, server binary, and short-form for messages.</code>
<code>apachectl=</code><code>/usr/local/apache/bin/apachectl</code>
<code>httpd=</code><code>/usr/local/apache/bin/httpd</code>
<code>prog=httpd</code>
<code>pidfile=${PIDFILE-</code><code>/var/run/httpd24</code><code>.pid}</code>
<code>lockfile=${LOCKFILE-</code><code>/var/lock/subsys/httpd24</code><code>}</code>
<code>RETVAL=0</code>
<code>STOP_TIMEOUT=${STOP_TIMEOUT-10}</code>
<code># The semantics of these two functions differ from the way apachectl does</code>
<code># things -- attempting to start while running is a failure, and shutdown</code>
<code># when not running is also a failure. So we just do it the way init scripts</code>
<code># are expected to behave here.</code>
<code>start() {</code>
<code> </code><code>echo</code> <code>-n $</code><code>"Starting $prog: "</code>
<code> </code><code>LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS</code>
<code> </code><code>RETVAL=$?</code>
<code> </code><code>echo</code>
<code> </code><code>[ $RETVAL = 0 ] && </code><code>touch</code> <code>${lockfile}</code>
<code> </code><code>return</code> <code>$RETVAL</code>
<code>}</code>
<code># When stopping httpd, a delay (of default 10 second) is required</code>
<code># before SIGKILLing the httpd parent; this gives enough time for the</code>
<code># httpd parent to SIGKILL any errant children.</code>
<code>stop() {</code>
<code> </code><code>echo</code> <code>-n $</code><code>"Stopping $prog: "</code>
<code> </code><code>killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd</code>
<code> </code><code>RETVAL=$?</code>
<code> </code><code>echo</code>
<code> </code><code>[ $RETVAL = 0 ] && </code><code>rm</code> <code>-f ${lockfile} ${pidfile}</code>
<code>reload() {</code>
<code> </code><code>echo</code> <code>-n $</code><code>"Reloading $prog: "</code>
<code> </code><code>if</code> <code>! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&</code><code>/dev/null</code><code>; </code><code>then</code>
<code> </code><code>RETVAL=6</code>
<code> </code><code>echo</code> <code>$</code><code>"not reloading due to configuration syntax error"</code>
<code> </code><code>failure $</code><code>"not reloading $httpd due to configuration syntax error"</code>
<code> </code><code>else</code>
<code> </code><code># Force LSB behaviour from killproc</code>
<code> </code><code>LSB=1 killproc -p ${pidfile} $httpd -HUP</code>
<code> </code><code>if</code> <code>[ $RETVAL -</code><code>eq</code> <code>7 ]; </code><code>then</code>
<code> </code><code>failure $</code><code>"httpd shutdown"</code>
<code> </code><code>fi</code>
<code> </code><code>fi</code>
<code># See how we were called.</code>
<code>case</code> <code>"$1"</code> <code>in</code>
<code> </code><code>start)</code>
<code> </code><code>start</code>
<code> </code><code>;;</code>
<code> </code><code>stop)</code>
<code> </code><code>stop</code>
<code> </code><code>status)</code>
<code> </code><code>status -p ${pidfile} $httpd</code>
<code> </code><code>restart)</code>
<code> </code><code>condrestart|try-restart)</code>
<code> </code><code>if</code> <code>status -p ${pidfile} $httpd >&</code><code>/dev/null</code><code>; </code><code>then</code>
<code> </code><code>stop</code>
<code> </code><code>start</code>
<code> </code><code>force-reload|reload)</code>
<code> </code><code>reload</code>
<code> </code><code>graceful|help|configtest|fullstatus)</code>
<code> </code><code>$apachectl $@</code>
<code> </code><code>*)</code>
<code> </code><code>echo</code> <code>$</code><code>"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"</code>
<code> </code><code>RETVAL=2</code>
<code>esac</code>
<code>exit</code> <code>$RETVAL</code>
=========================================完==========================================
下篇将對編譯安裝的http-2.4.9進行功能測試
本文轉自 jinlinger 51CTO部落格,原文連結:http://blog.51cto.com/essun/1379986,如需轉載請自行聯系原作者