httpd-2.4的新特性:

    1) MPM支持在运行时装载;

        --enalbe-mpm-shared=all --with-mpm={prefork|worker|event}

    2) 支持event mpm

    3) 异步读写

    4) 在每模块及每目录分别使用不同的日志级别

    5) 每请求的配置: <If>,<Elseif>

    6) 增强版的表达式分析器

    7) 毫秒级的keep alive的timeout

    8) 基于FQDN的虚拟主机不再需要NameVirtualHost指令;

    9) 支持用户使用自定义变量

    新增的模块:

        mod_proxy_fcgi:  支持用fastcgi的方式连接后端的php

        mode_ratelimit:  速率限定,限制用户访问时传输的速率

        mod_request:  对用户请求做更强的过滤功能

        mod_remoteip: 对用户访问的IP地址有更强的控制能力

    修改了一些配置机制:

        不再支持使用order,allow,deny定义基于ip的访问控制,改为require

依赖关系:

    因为httpd程序依赖于apr和apr-util所以在安装httpd之前需要先安装apr和apr-util,centos6.5的yum源提供的apr为1.3.9版本而httpd需要1.4.0以上的版本支持,所以apr和apr-util也需要手动安装.步骤1-6为解决依赖关系的步骤.


配置过程:

1.安装开发者工具包

[root@test2 ~]# yum groupinstall 'Development tools'
[root@test2 ~]# yum groupinstall 'Server Platform Development'

2.通过xftp把apr-1.5.0.tar.bz2,apr-util-1.5.3.tar.bz2和httpd-2.4.9.tar.bz2三个包上传到虚拟机的根目录

3.解压apr-1.5.0.tar.bz2包

[root@test2 ~]# tar xf apr-1.5.0.tar.bz2 
[root@test2 ~]# cd apr-1.5.0

4.把apr安装到/usr/local/apr下这样不用影响系统的原有的apr版本的使用

[root@test2 apr-1.5.0]# ./configure --prefix=/usr/local/apr
[root@test2 apr-1.5.0]# make && make install

等待安装完成,查看一下安装目录

[root@test2 apr-1.5.0]# ls /usr/local/apr/
bin  build-1  include  lib
[root@test2 apr-1.5.0]# ls /usr/local/apr/lib
apr.exp  libapr-1.a  libapr-1.la  libapr-1.so  libapr-1.so.0  libapr-1.so.0.5.0  pkgconfig

5.解压apr-util-1.5.3.tar.bz2包

[root@test2 ~]# tar xf apr-util-1.5.3.tar.bz2

6.同样把apr-util装到新位置/usr/local/apr-util.因为apr-util是apr的一个工具,而新版本的apr又安装在了不同的位置,所以要apr-util指定apr的安装位置

[root@test2 apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@test2 apr-util-1.5.3]# make && make install

7.解压httpd-2.4.9.tar.bz2包

[root@test2 ~]# tar xf httpd-2.4.9.tar.bz2

8.编译安装httpd-2.4.9

[root@test2 httpd-2.4.9]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd 
--enable-so --enable-ssl --enable-cgi --enable-rewrite --with-pcre --with-zlib --with-apr
=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=e
vent --enable-modules=most[root@test2 httpd-2.4.9]# make && make install

    --prefix=/usr/local/apache:  httpd的安装路径

    --sysconfdir=/etc/httpd:  配置文件的安装路径

    --enable-so:  支持DSO的方式动态装卸模块,默认启用

    --enable-ssl:  编译启用ssl,rpm –qa|grep opensll要能查看到openssl-devel

    --enable-cgi:  默认启用cgi模块

    --enable-rewrite:  支持url重写,服务器自动重写url以跳转到新位置

    --with-pcre:  支持pcre,perl的正则表达库rpm –qa|grep pcre要能查看到pcre-devel

    --with-zlib:  支持在网络传输时使用压缩库

    --with-apr=/usr/local/apr:  指定apr位置

    --with-apr-util=/usr/local/apr-util:  指定apr-util位置

    --enable-mpms-shared=all --with-mpm=event:  默认使用event模式

    --enable-modules=most: 编译大多数常用模块

9.把httpd的脚本添加到PATH路径

[root@test2 ~]# vim /etc/profile.d/httpd24.sh
export PATH=/usr/local/apache/bin:$PATH
[root@test2 ~]# source /etc/profile.d/httpd24.sh

10.测试httpd程序是否正常启动

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_centos在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_linux_02

11.头文件导出

[root@test2 apache]# ln -sv /usr/local/apache/include/ /usr/include/httpd2

12.添加man手册

[root@test2 apache]# vim /etc/man.config

在配置文件中添加man文件夹的位置

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_linux_03

13.编译安装后的环境介绍

[root@test2 apache]# ls
bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

    bin: 二进制程序目录

    cgi-bin: 服务器端脚本目录

    htdocs: 默认主页位置

    error: 默认错误页面

    icons: 图标

    include: 头文件

    logs: 日志

    modules: 模块

14.MPM配置

启用MPM功能

[root@test2 httpd]# vim httpd.conf
# Server-pool management (MPM specific)
Include /etc/httpd/extra/httpd-mpm.conf

MPM配置文件位置

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_centos_04

如果想要更换MPM,需要修改httpd位置文件

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_linux_05

修改为

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_centos_06

用httpd -M命令查看httpd加载的模块

在centos6.5上编译安装httpd-2.4和2.4版本特性介绍_centos_07