Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)
下载包
# cd /usr/local/src/
下载地址如果无效了可以到镜像站去下载最新的
# wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/httpd/httpd-2.4.10.tar.gz
# wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
# wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz
解压软件包
# tar -zxvf httpd-2.4.10.tar.gz
# tar -zxvf apr-1.5.0.tar.gz
# tar -zxvf apr-util-1.5.3.tar.gz
# cp -rf apr-1.5.0 httpd-2.4.10/srclib/apr
# cp -rf apr-util-1.5.3 httpd-2.4.10/srclib/apr-util
# cd /usr/local/src/httpd-2.4.10
# yum install gcc -y
# ./configure --prefix=/usr/local/httpd --with-mpm=prefork --enable-so --enable-rewrite --enable-mods-shared=all --enable-nonportable-atomics=yes --disable-dav --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-ssl --with-included-apr --enable-modules=all --enable-mods-shared=all
如果有报错参考如下
--prefix 指定安装到哪里, --enable-so 表示启用DSO [1] --enable-deflate=shared 表示共享的方式编译deflate,后面的参数同理
报错
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
# yum install pcre pcre-devel -y
报错
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
# yum install zlib-devel -y
错误
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
# yum install openssl-devel -y
# make && make install
# ls /usr/local/httpd/modules 扩展模块
# /usr/local/httpd/bin/httpd -M 查看加载的模块.
# /usr/local/httpd/bin/apachectl start 启动服务