1.安装依赖库:“Development  Tools”  “Server Platform Development”  pcre-devel

2.安装apr,apr-util

  从yum源安装或去apr网站下载安装包,这是采用编译安装。

安装apr:

  cd apr

  ./configure --prefix=/usr/local/apr

安装apr-util:

  cd apr-util

  ./configure --prefilx=/usr/local/apr-util  --with-apr=/usr/local/apr

3.安装apache

./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-ssl --enable-so --enable-rewrite --enable-zlib --enable-pcre  --enable-cache --enable-cache-disk  --enable-cgi --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork

4.修改httpd的主配置文件,设置其Pid文件的路径

在httpd.conf文件中添加如下行:

  PidFile “/var/run/httpd.pid”

5.添加环境变量

vim /etc/profile.d/httpd.sh

export PATH=/usr/loca/apache/bin:$PATH

6.

提供SysV服务脚本/etc/rc.d/init.d/httpd,内容如下:

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL

而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/httpd

加入服务列表:
# chkconfig --add httpd

编译安装apache的更多相关文章

  1. centos手动编译安装apache、php、mysql

    64位centos 5.5手动安装lamp,要求curl.json.pdo_mysql.gd,记录如下. centos 5.4.5.5.5.6的内核都是2.6.18,都可以安装php 5.3. 卸载旧 ...

  2. Linux下编译安装Apache Http Server

    Linux下编译安装Apache Http Server [TOC] 1.下载httpd-2.4.12.tar.bz2 wget http://mirror.bit.edu.cn/apache/htt ...

  3. linux中编译安装Apache、PHP、MySQL(上)

    1.简介 在阿里云买了个云服务器,一直没时间折腾.过了近十天了吧,才有时间好好玩玩这个云服务器.自己是做Web开发的,所以我需要的开发环境是LAMP.之前打算是采用yum安装,不过yum安装apach ...

  4. Linux 通过编译安装apache服务以及配置

    Linux 编译安装apache服务 一.安装 1.通过编译安装,首先需要下载源代码安装包 apache下载链接:http://httpd.apache.org/download.cgi 2.解开源代 ...

  5. Linux学习之编译安装apache

    疯狂吐槽腾某云..编译安装apache折腾了一下午..还是我不太熟练. 首先要先准备好安装apache的三个依赖包以及apache包.(一定要准备好!!折腾了一下午的小白握拳!!) -rw-r--r- ...

  6. 编译安装Apache httpd和php搭建KodExplorer网盘

    编译安装Apache httpd和php搭建KodExplorer网盘 环境说明: 系统版本    CentOS 6.9 x86_64 软件版本    httpd-2.2.31        php- ...

  7. Linux编译安装Apache+PHP

    Linux编译安装Apache+PHP 来自:自学it网,http://www.zixue.it/. 1]编译安装Apache+PHP 1.安装程序依赖库和开发环境   为了省事把所需要的库文件全都安 ...

  8. 编译安装Apache:出现错误configure: error: mod_deflate

    在进行编译安装Apache时,出现如下错误 checking whether to enable mod_deflate... configure: error: mod_deflate has be ...

  9. Ubuntu编译安装Apache

    第一步:编译安装依赖包apr,apr-util和pcre ./configure --prefix= make && make install 第二步:编译安装Apache ./con ...

  10. Centos6.7 编译安装 Apache PHP

    Centos6.7 编译安装 Apache PHP 原文地址:http://www.cnblogs.com/caoguo/p/4968039.html ##### Apache 编译安装 #### [ ...

随机推荐

  1. 使用ArcGIS JavaScript API 3.18 加载天地图

    对于中国开发者在创建GIS应用的时候,往往比较头疼的是底图资源的缺乏.其实国家测绘地信局就提供一个很好的免费资源:天地图.使用ArcGIS API的开发人员可以直接利用该资源作为地图应用的底图. Ar ...

  2. C++序列化、反序列化

    几个常见的库 http://stackoverflow.com/questions/3637581/fastest-c-serialization Boost: Fast, assorted C++ ...

  3. 通知、block

    =================================== 通知 =================================== 一.通知(NSNotification) // N ...

  4. PacificA中的租约与失效检测解读

    PacificA是微软的在基于log的分布式存储系统中的复制技术. 由于配置管理器维护着当前配置的真实情况,因此主节点不必保持不变. 这是因为配置的本地视图在不同服务器上是不必同步的. 特别是,我们必 ...

  5. Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "xxxxxxx".

    在SQL SERVER 2008 R2下用Windows 身份认证的登录名创建了一个访问ORACLE数据库的链接服务器xxxxx,测试成功,木有问题,但是其它登录名使用该链接服务器时,报如下错误: 消 ...

  6. Windows系统下Oracle每天自动备份

    linux和unix下面使用shell可以很方便实现,如果windows环境下可以结合计划任务实现 创建备份目录d:\backup, 创建批处理命令Bak.bat,编写备份脚本 exp user/pa ...

  7. SQL Server 聚合函数算法优化技巧

    Sql server聚合函数在实际工作中应对各种需求使用的还是很广泛的,对于聚合函数的优化自然也就成为了一个重点,一个程序优化的好不好直接决定了这个程序的声明周期.Sql server聚合函数对一组值 ...

  8. ORA-01033因误删表空间文件导致的解决方案

    该类问题通常是由于表空间操作不当引起的.解决方法: SQL*Plus无法连接,显示以下错误:ORA-01033:ORACLE initialization or shutdown in progres ...

  9. 【转】Linux常用命令大全

    原文地址:http://www.php100.com/html/webkaifa/Linux/2009/1106/3485.html 系统信息 arch 显示机器的处理器架构(1) uname -m ...

  10. spring项目部署到resin4中的无法注入问题

    碰到个奇葩事啊,一个spring的项目拿到客户现场部署到resin4中,启动后各种报无法注入bean,找不到bean的问题.出现大量下图的错误: nested exception is org.spr ...