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. UIImageView 自带动画+N张图片实现很炫的动画

    gitHub上又看到个很炫的动画:https://github.com/MartinRGB/GiftCard-iOS   看了看他的代码,发现核心动画(就是把按钮包装成一个礼物盒)其实很简单,就是把一 ...

  2. 阴影 box-shadow

    语法: box-shadow:none | <shadow> [ , <shadow> ]* <shadow> = inset? && <le ...

  3. .net 已知图片的网络路径,通过浏览器下载图片

    没什么技术含量,主要留给自己查找方便: 如题,知道图片的完整网络路径的情况下,在浏览器中下载图片的实现: 下面这个方法实现的是把图片读取为byte数组: private byte[] GetImage ...

  4. Ignite安装配置——中篇

    Linux Ignite配置——上篇大体介绍了一下Ignite工具的功能.特性等,以及如何在Linux 上安装配置.从上篇可见Ignite安装非常的简单方便.下面介绍一下Ignite Reposito ...

  5. ORA-01336: specified dictionary file cannot be opened

    这篇介绍使用Logminer时遇到ORA-01336: specified dictionary file cannot be opened错误的各种场景 1:dictionary_location参 ...

  6. MySQL高可用架构之MHA

    简介: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司)开发,是 ...

  7. 基于注解的SpringMVC

    相比传统的继承Controller体系中某些类的方式,SpringMVC的注解具有以下优点: 1.Controller不再需要继承某个特定类,只是简单的POJO. 2.请求映射的配置非常方便灵活. 3 ...

  8. ASCII 计算机码

      回车 代码:CR ASCII码:\ r ,十六进制,0x0d,回车的作用只是移动光标至该行的起始位置: 换行 代码:LF ASCII码:\ n ,十六进制,0x0a,换行至下一行行首起始位置:

  9. linux basic commands

    1. man - an interface to the on-line reference manuals $man man 2. apt - advanced package tool SEE A ...

  10. Ubuntu 配置 no-ip

    安装Python开发依赖包 sudo apt-get install python-dev 配置PIP并安装noipy sudo apt-get install python-pip sudo pip ...