1.下载APache:http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.bz2 /usr/local/src/
2.tar jxvf httpd-2.2.31.tar.bz2
3.cd httpd-2.2.31
4. ./configure \
--prefix=/usr/local/apache2 --with-included-apr \ #这里很重要Apache自带apr包,不然默认会要求提前安装。 --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
error: mod_deflate has been requested but can not be built due to prerequisite failures
解决办法是:yum install -y zlib-devel
为了避免在make的时候出现错误,所以最好是提前先安装好一些库文件:
yum install -y pcre pcre-devel apr apr-devel
5.make
6.make install
ls /usr/local/apache2/
7.启动Apache:/usr/local/apache2/bin/apachectl start 可能会有ServerName报错,进入配置文件/usr/local/apache2/conf/httpd.conf
#ServerName #去掉,改为ServerName localhost:80; /usr/local/apache2/bin/apachectl restart 重启进程
8.检查:ps aux |grep httpd
/usr/local/apache2/bin/apachectl -M 查看模块
/usr/local/apache2/bin/apachectl -l 查看静态模块
/usr/local/apache2/bin/apachectl -t 检查配置文件错误
ls /usr/local/apache2/modules:绿色的,.so结尾的就是动态加载的模块
ls /usr/local/apache2/bin/httpd :静态加载模块文件
/usr/local/apache2/bin/apachectl stop restart graceful (重新加载配置文件,不是重启进程,效果和restart类似)
原文:http://11103372.blog.51cto.com/11093372/1733033