1.下载源码包
cd /usr/local/src/
wget
2.解压缩源码包
tar -zxvf httpd-2.2.31.tar.gz
3.配置编译参数:
[root@localhost src]# cd httpd-2.2.16
[root@localhost httpd-2.2.16]# ./configure \
--prefix=/usr/local/apache \
--with-included-apr \
--enable-so \--enable-deflate=shared \--enable-expires=shared \--enable-rewrite=shared \--with-pcre--prefix
指定安装到哪里, --enable-so
表示启用DSO --enable-deflate=shared
表示共享的方式编译deflate,后面的参数同理。如果这一步你出现了这样的错误:
error: mod_deflate has been requested but can not be built due to prerequisite failures
遇到错误:configure: error: no acceptable c compiler found in $path
解决办法: yum install gcc
解决办法是:
yum install -y zlib-devel
为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件:
yum install -y pcre pcre-devel apr apr-devel
4.编译完成后进行make安装,用echo $? 检查结果是不是0,再make install 进行安装.
5.启动httpd
/usr/local/apache/bin/apachectl start /restart /stop /graceful--重新加载配置文件
/usr/local/apache/bin/apachectl -M 列出模块 -l 列出静态的模块 -t 查看配置文件是否错误