有了前两篇的介绍我相信大家对http已经有了基本的认识,今天我们来说一下httpd-2.4,这是Apache对于httpd-2.2的比较大的改进,增加许多实用性的新功能,我们来大致看一下。
(1) MPM支持运行DOS机制;
(2) 支持event MPM;
(3) 支持异步读写;
(4) 支持每模块及每个目录分别使用各自的日志级别;
(5) 每请求配置;<If>
(6) 增强版的表达式分析器;
(7) 支持毫秒级的keepalive timeout;
(8) 基于FQDN的虚拟主机不再需要NameVirtualHost指令;
(9) 支持用户自定义变量;
(1) mod_proxy_fcgi#与PHP结合的模块
(2) mod_ratelimit#限制下载速率的模块
(3) mod_remoteip#设定远程客户端IP
修改的配置机制:
不再支持使用order, allow, deny定义基于ip的访问控制,改为require
在编译安装时httpd依赖于apr, apr-util这两个包,其中apr(Apache portable runtime)叫做Apache可移植运行时环境,这个东西可以简单的理解成Apache的虚拟机,作用是为了使httpd代码可以在不同的操作系统上运行的。因为httpd-2.4需要的apr版本最低为1.4而我的系统上的是1.3.9,所以我们需要将apr也一同编译安装。
[root@localhost ~]# yum groupinstall "Development tools" "Server Platform Development" y
[root@localhost ~]# tar -xf apr-1.5.0.tar.bz2
[root@localhost ~]# cd apr-1.5.0
[root@localhost apr-1.5.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.0]# make && make install
[root@localhost ~]# tar xf apr-util-1.5.3.tar.bz2
[root@localhost ~]# cd apr-util-1.5.3
[root@localhost apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util with-apr=/usr/local/apr
[root@localhost apr-util-1.5.3]# make && make install
[root@localhost ~]# tar xf httpd-2.4.10.tar.bz2
[root@localhost ~]# cd httpd-2.4.10
[root@localhost httpd-2.4.10]# ./configure help#查看config选项
[root@localhost httpd-2.4.10]# ./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=prefork
[root@localhost httpd-2.4.10]# make && make install
4、httpd-2.4编译参数详解:
--prefix:#安装路径
--sysconfdir:#指定配置文件路径
--enable-so:#DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效
--enable-ssl:#支持SSL/TLS,可实现https访问 需已安装openssl-devel
--enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启)
--enable-rewrite:#启用Rewrite功能,URL重写
--enable-deflate:#支持压缩功能
--with-zlib:#使用指定的zlib库,不指定路径会自动寻找
--with-pcre:#使用指定的PCRE库,不指定路径会自动寻找 需已安装pcre-devel
--with-apr:#指定apr安装路径
--with-apr-util:#指定apr-util安装路径
--enable-mpms-shared:#支持动态加载的MPM模块,可选参数:all
--with-mpm:#设置默认启用的MPM模式,{prefork|worker|event}
--enable-modules:#支持动态启用的模块,可选参数:all,most,few,reallyall
5、编译后的辅助工作
[root@localhost httpd-2.4.10]# vim /etc/profile.d/httpd24.sh#添加环境变量
1 export PATH=/usr/local/apache/bin:$PATH
[root@localhost httpd-2.4.10]# . /etc/profile.d/httpd24.sh#重读环境变量脚本
[root@localhost httpd-2.4.10]# ln -sv /usr/local/apache/include/ /usr/include/httpd24#导出头文件
[root@localhost httpd-2.4.10]# vim /etc/man.config#导出帮助文档
43 MANPATH /usr/local/apache/man
[root@localhost httpd-2.4.10]# vim /etc/rc.d/init.d/httpd24 #编写服务脚本
1 #!/bin/bash
2 #
3 # httpd Startup script for the Apache HTTP Server
4 #
5 # chkconfig: - 85 15
6 # description: The Apache HTTP Server is an efficient and extensible \
7 # server implementing the current HTTP standards.
8 # processname: httpd
9 # config: /etc/httpd/conf/httpd.conf
10 # config: /etc/sysconfig/httpd
11 # pidfile: /var/run/httpd/httpd.pid
12 #
13 ### BEGIN INIT INFO
14 # Provides: httpd
15 # Required-Start: $local_fs $remote_fs $network $named
16 # Required-Stop: $local_fs $remote_fs $network
17 # Should-Start: distcache
18 # Short-Description: start and stop Apache HTTP Server
19 # Description: The Apache HTTP Server is an extensible server
20 # implementing the current HTTP standards.
21 ### END INIT INFO
22
23 # Source function library.
24 . /etc/rc.d/init.d/functions
25
26 if [ -f /etc/sysconfig/httpd ]; then
27 . /etc/sysconfig/httpd
28 fi
29
30 # Start httpd in the C locale by default.
31 HTTPD_LANG=${HTTPD_LANG-"C"}
32
33 # This will prevent initlog from swallowing up a pass-phrase prompt if
34 # mod_ssl needs a pass-phrase from the user.
35 INITLOG_ARGS=""
36
37 # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
38 # with the thread-based "worker" MPM; BE WARNED that some modules may not
39 # work correctly with a thread-based MPM; notably PHP will refuse to start.
40
41 # Path to the apachectl script, server binary, and short-form for messages.
42 apachectl=/usr/local/apache/bin/apachectl
43 httpd=${HTTPD-/usr/local/apache/bin/httpd}
44 prog=httpd
45 pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
46 lockfile=${LOCKFILE-/var/lock/subsys/httpd}
47 RETVAL=0
48 STOP_TIMEOUT=${STOP_TIMEOUT-10}
49
50 # The semantics of these two functions differ from the way apachectl does
51 # things -- attempting to start while running is a failure, and shutdown
52 # when not running is also a failure. So we just do it the way init scripts
53 # are expected to behave here.
54 start() {
55 echo -n $"Starting $prog: "
56 LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
57 RETVAL=$?
58 echo
0人
|
了这篇文章 |