1. 在编译安装apache之前需要准备好其他安装包以支持apache,否则会报错(可以用yum安装)

 apr-1.5.0.tar.gz,apr-util-1.5.3.tar.gz,pcre-8.35.tar.gz,httpd-2.4.9.tar.bz2  

# yum -y install apr-* apr-util-* pcre-*

2. 准备http的安装包,并编译安装

# ./configure --prefix=/usr/local/apache    \\apache安装目录

 --enable-so                               \\支持动态共享模块

 --enable-rewrite                          \\启动rewrite模块

 --enable-mods-shared=most                 \\安装大多数模块为动态模块

 --enable-mpms-shared=all                  \\支持全波多道处理方式

 --with-mpm=event                          \\设置httpd工作模式

#make && make install                       \\编译&&安装

#/usr/local/apache/bin/apachect1  start      \\启动apache

3. 将apache注册为系统服务

# cp /usr/local/apache/bin/apachect1  /etc/rc.d/init.d/httpd   \\将apachect1改名为httpd   # vim /etc/rc.d/init.d/httpd


--- 在 #!/bin/bash 下 添加如下两行 ----

#chkconfig: 2345 85 15                     \\启动级别  注意:# 这个符号一定要添加,否则启                                              动时会报错  //service httpd does not support chkconfig//  

#description: Apache                       \\注解  

4. 保存退出输入如下两行就可以使用service启动apache了

# chkconfig --add httpd                   \\添加apache为系统fuw

# chkconfig httpd on                      \\设置开机自启动

# service httpd restart