进入/usr/local/src/
cd /usr/local/src
下载httpd-2.2.34.tar.bz2
wget http://mirrors.sohu.com/apache/httpd-2.2.34.tar.bz2
解压压缩包
tar -jxvf httpd-2.2.34.tar.bz2
创建Apache安装目录/usr/local/apache2
mkdir /usr/local/apache2
配置Apache安装信息
cd httpd-2.2.34
./configure \
--prefix=/usr/local/apache2/ \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--with-pcre
参数解释:
--prefix=/usr/local/apache2/ 指定Apache安装路径
--with-included-apr 使用捆绑apr的副本(可以不装)
--enable-so 以动态共享对象编译(必须安装)
--enable-deflate=shared 缩小传输编码的支持
--enable-expires=shared 期满头控制
--enable-rewrite=shared 基于规则的url操控
--with-pcre 依赖pcre
编译Apache
make
安装Apache
make install
问题集锦:
在./configure过程中,可能会出现如下错误
错误1:
error: no acceptable C compiler found in $PATH
原因:缺少C编译器
解决:安装gcc
yum –y install gcc
错误2:
error: mod_deflate has been requested but can not be built due to prerequisite failures
解决:
yum install zlib-devel
小建议
为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件:
yum install -y pcre pcre-devel apr apr-devel