1. 下载


    [root@localhost ~]# cd /usr/local/src

    [root@localhost src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz

  2. 解压

    tar zxvf httpd-2.2.31.tar.gz

  3. 进入目录



    [root@localhost src]# ls

    httpd-2.2.31  httpd-2.2.31.tar.bz2  httpd-2.2.31.tar.gz

    [root@localhost src]# cd /usr/local/src/httpd-2.2.31

    [root@localhost httpd-2.2.31]# ls

    ABOUT_APACHE  config.layout  httpd.spec      LICENSE        README.platforms

    acinclude.m4  configure      include         Makefile.in    README-win32.txt

    Apache.dsw    configure.in   INSTALL         Makefile.win   ROADMAP

    build         docs           InstallBin.dsp  modules        server

    BuildAll.dsp  emacs-style    LAYOUT          NOTICE         srclib

    BuildBin.dsp  httpd.dep      libhttpd.dep    NWGNUmakefile  support

    buildconf     httpd.dsp      libhttpd.dsp    os             test

    CHANGES       httpd.mak      libhttpd.mak    README         VERSIONING

  4. 配置编译参数

    --prefix 指定安装到哪里, --enable-so 表示启用DSO --enable-deflate=shared 表示共享的方式编译deflate,后面的参数同理。如果这一步你出现了这样的错误:

    error:mod_deflate has been repuested but can not be built due to preerquisite falures


解决办法是:

[root@localhost httpd-2.2.31]# yum install -y zlib-devel

为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件

yum install -y pcre pcre-devel apr ape-devel


[root@localhost httpd-2.2.31]# ./configure \

> --prefix=/usr/local/apache2 \

> --with-included-apr \

> --enable-so \

> --enable-deflate=shared \

> --enable-expires=shared \

> --enable-rewrite=shared \

> --with-pcre

5.编译


[root@localhost httpd-2.2.31]# make


6.安装

make install