一、httpd 简介
目前CENTOS7默认安装是HTTPD2.4,但是CENTOS6上默认是安装HTTPD2.2,CENTOS6如果要安装HTTPD2.4,需要通过编译安装实现,一般情况下,centOS7默认是安装httpd2.4,若自己编译特殊的模块,需要源码编译安装。httpd2.4源码在
http://httpd.apache.org 下载。
源码编译的优势:
1)自定义软件功能;
2)优化编译参数,提高性能;
3)解决不必要的软件间依赖;
4)方便清理与卸载。
二、httpd的版本
httpd-1.3
httpd-2.0
httpd-2.2
httpd-2.4
三、编译安装
httpd-2.4 依赖于1.4+及以上版本的apr(apache portable runtime,能实现httpd跨平台运行),apr-util,pcre。
-
yum install expat-devel (XML解析)
2.获得apr的源码包: wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz

3.然后解压下载好的源码包到/usr/local/usr:
tar -xzvf apr-1.7.0.tar.gz -C /usr/local/src
4.到源码包目录下安装:
1)cd /usr/local/src/apr-1.7.0
2)./configure --prefix=/usr/local/apr

3)make
4)make install

5.获得apr-util的源码包:
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz 
6.然后解压下载好的源码包到/usr/local/src:
tar -xzvf apr-util-1.6.1.tar.gz -C /usr/local/src

7.到源码包目录下安装:
1)cd /usr/local/src/apr-util-1.6.1
2) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

3)make
4)make install

8.获得pcre的源码包:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.43.tar.gz

9.然后解压下载好的源码包到/usr/local/usr:
tar -xzvf pcre-8.43.tar.gz -C /usr/local/src

10.到源码包目录下安装:
1)cd /usr/local/src/pcre-8.43
2)./configure --prefix=/usr/local/pcre

3)make
4)make install 11..获得apr-util的源码包:
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz

12.然后解压下载好的源码包到/usr/local/src:
tar -xzvf httpd-2.4.39.tar.gz -C /usr/local/src

13.到源码包目录下安装:
1)cd /usr/local/src/httpd-2.4.39
2)./configure --prefix=/usr/local/apache24 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre

3)make4)make install四、(make 报错, 解决问题,make clean 把生成 的中间文件删掉 再 make)configure: 探测操作系统目标环境 检查有没有cc或gcc configure是shell脚本 生成Makefile make : 编译 (gcc)make install : 安装 /usr/local/src : 存放源码包