准备工作:
1.下载http源码
2.下载apr-util源码
3.下载apr源码
4.下载pcre源码
5.讲上述4个源码包都放到 /home/hhc(你的用户名)/Downloads 下
6.运行下面的脚本
cd /home/hhc/Downloads/
# APR and APR-Util
# Make sure you have APR and APR-Util already installed on your system. If you don't, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from Apache APR, unpack them into /httpd_source_tree_root/srclib/apr and /httpd_source_tree_root/srclib/apr-util (be sure the directory names do not have version numbers; for example, the APR distribution must be under /httpd_source_tree_root/srclib/apr/) and use ./configure's --with-included-apr option. On some platforms, you may have to install the corresponding -dev packages to allow httpd to build against your installed copy of APR and APR-Util.
gzip -d /home/hhc/Downloads/httpd-2.4.4.tar.gz
tar xvf /home/hhc/Downloads/httpd-2.4.4.tar
mv -f /home/hhc/Downloads/httpd-2.4.4 /usr/local
gzip -d /home/hhc/Downloads/apr-1.4.8.tar.gz
tar xvf /home/hhc/Downloads/apr-1.4.8.tar
mv apr-1.4.8 apr
mv -f /home/hhc/Downloads/apr /usr/local/httpd-2.4.4/srclib/
gzip -d /home/hhc/Downloads/apr-util-1.5.3.tar.gz
tar xvf /home/hhc/Downloads/apr-util-1.5.3.tar
mv apr-util-1.5.3 apr-util
mv -f /home/hhc/Downloads/apr-util /usr/local/httpd-2.4.4/srclib/
# Perl-Compatible Regular Expressions Library (PCRE)
# This library is required but not longer bundled with httpd. Download the source code from http://www.pcre.org, or install a Port or Package. If your build system can't find the pcre-config script installed by the PCRE build, point to it using the --with-pcre parameter. On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.
gzip -d /home/hhc/Downloads/pcre-8.34.tar.bz2
tar xvf /home/hhc/Downloads/pcre-8.34.tar
cd pcre-8.34
./configure
make
make install
cd /usr/local/httpd-2.4.4
./configure --with-included-apr
make
make install
7.安装好后按照官网教程运行
bin/apachectl -k start
8.此时可能有问题:
httpd error while loading shared libraries: libpcre.so.1
是因为找不到libpcre.so.1,但是在前面我们已经安装了这个东西,网上nignx安装报同样问题的解决方法不适用于httpd,正确方法是
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
或者在/etc/profile文件中加入上面一行语句,然后运行
source /etc/profile
生效后,再启动httpd:
bin/apachectl -k start