以CentOS-6.4安装的基础上进行编译安装Apache:
检查gcc编译器:
gcc-v #检查gcc编译器
yum -y install gcc automake autoconf libtool make #安装GCC
yum install gcc gcc-c++ #安装C++编译器
#下载Apache
mkdir /usr/local/source
cd /usr/local/source
wget http://archive.apache.org/dist/httpd/httpd-2.2.10.tar.gz
#下载完后解压
tar xzfv httpd-2.2.10.tar.gz
#附上其他版本的Apache地址http://archive.apache.org/dist/httpd/
#简单检查还需要安装那些运行库
cd /usr/local/source/httpd-2.2.10
#配置
./configure
#加入一些常用的参数进行配置
./configure --prefix=/usr/local/apache2 #设置安装目录
--sysconfdir=/etc/httpd #设置配置文件的目录
--with-zlib=/usr/local/zlib #增加zlib的支持,可以使用gzip压缩
--with-include-apr #使用绑定的apr副本
--enable-so #动态加载模块
--enable-deflate=share #缩小传输编码支持
--enable-expire=share #期满值控制
--enable-rewrite=share #url重写支持
--enable-static-support #使用静态编译
--with-mpm=worker #使用mpm 的worker模式,更多模式与编译参数参考apache文档
![](http://static.oschina.net/uploads/space/2015/0119/162029_K7cg_1433294.png)
提示缺少zlib的支持:
#下载zlib运行库
cd /usr/local/source
wget http://down1.chinaunix.net/distfiles/zlib-1.2.7.tar.gz
#编译安装
cd /usr/local/source/zlib-1.2.7
./configure
make
make install
history
!95 #将会执行apache配置的命令
make&&make install
cd /usr/local/apache2/bin
./apachectl start #启动apache
#关闭防火墙
service iptables stop
#暂时关闭selinux
setrnforce 0
#在浏览器中输入地址访问,
127.0.0.1
#开机时自动启动
echo '/usr/local/apache2/bin/apachectl start' >> /etc/rc.d/rc.local