centos安装apache

centos版本
[root@Slave1 pcre-8.33]# rpm -q centos-release
centos-release-5-8.el5.centos

系统如果有(rpm -qa | grep httpd ,rpm -qa | grep apr),先卸载掉
[root@Slave1 httpd-2.4.4]# rpm -e  gnome-user-share-0.10-6.el5.i386
[root@Slave1 httpd-2.4.4]# rpm -e httpd-2.2.3-65.el5.centos.3
[root@Slave1 httpd-2.4.4]# rpm -e apr-util-1.2.7-11.el5_5.2
[root@Slave1 httpd-2.4.4]# rpm -e apr-1.2.7-11.el5_6.5

安装依赖(需要先解压,进入解压后的目录)。下载apr apr-util 地址http://apr.apache.org/download.cgi ,pcre http://sourceforge.net/projects/pcre/files/pcre/
./configure --prefix=/var/zw/installed/apr1.4.6 && make && make install
./configure --prefix=/var/zw/installed/apr-util1.5.2 --with-apr=/var/zw/installed/apr1.4.6 && make && make install
./configure --prefix=/var/zw/installed/pcre-8.33  && make && make install

安装apache
tar zxvf httpd-2.4.4.tar.gz
./configure --prefix=/var/zw/installed/apache2.4.4 --enable-module=so --enable-module=rewrite --enable-shared=max  --datadir=/var/zw/installed/www    --with-apr=/var/zw/installed/apr1.4.6 --with-apr-util=/var/zw/installed/apr-util1.5.2  --with-pcre=/var/zw/installed/pcre-8.33 && make && make install

 说明:这里我们通过enable-module参数告诉设置脚本,我们需要启动so和rewrite模块,so模块是用来提DSO支持的apache核心模块,而rewrite模块则是用意实现地址重写的模块。enable-shared=max 这个参数的作用是编译apache时,把除了so以外的所有apache的标准模块都编译成DSO模块。而不是编译进apache核心内。

启动
/var/zw/installed/apache2.4.4/bin/apachectl start

测试启动成功,浏览器输入
http://192.168.1.101/  显示 it works表示启动成功。

-----------------