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,如需转载请自行联系原作者