安装前准备:

开发环境:Development Libraries 和 Development Tools

httpd环境包:apr-1.4.6.tar.bz2 和 apr-util-1.4.1.tar.bz2

httpd代码包:httpd-2.4.3.tar.bz2

确保安装之前的环境是干净的

1. 编译安装apr 和 apr -util

(1) 编译安装apr



# tar xf apr-1.4.6.tar.bz2

# cd apr-1.4.6

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

# make && make install



(2) 编译安装apr-util

# tar xf apr-util-1.4.1.tar.bz2

# cd apr-util-1.4.1

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make && make install

(3) httpd-2.4.3编译过程也要依赖于pcre-devel软件包,需要事先安装。此软件包系统光盘自带,因此,找到并安装即可。

2、编译安装httpd-2.4.3



首先下载httpd-2.4.3到本地,注意2.4.3之前的版本不支持event模块。而后执行如下命令进行编译安装过程:



# tar xf httpd-2.4.3.tar.bz2

# cd httpd-2.4.3

# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=event

# make && make install

3、修改httpd的主配置文件,设置其Pid文件的路径





编辑/etc/httpd/httpd.conf,添加如下行即可:

PidFile  "/var/run/httpd.pid"

4、提供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









接下来就可以启动服务进行测试了。

手动编译安装LAMP之httpd的更多相关文章

  1. 手动编译安装lamp之php

    转自马哥教育讲课文档 三.编译安装php-5.4.8 1.解决依赖关系: 请配置好yum源(可以是本地系统光盘)后执行如下命令: # yum -y groupinstall "X Softw ...

  2. 手动编译安装lamp之mysql

    转自马哥教育的讲课文档 二.安装mysql-5.5.28 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/mydata,而后需要 ...

  3. ubuntu10.04编译安装LAMP

    ubuntu10.04编译安装LAMP以及简单wordpress的使用 : http://linuxme.blog.51cto.com/1850814/971631 一.源码安装LAMP 网上有一堆关 ...

  4. CentOS 6编译安装lamp,并分别安装event模块方式和FPM方式的PHP

    任务目标: 编译安装LAMP 要求(1) 安装一个模块化的PHP 要求(2) 安装一个FPM的PHP 注意PHP需要最后一个安装,因为需要前两者的支持. 所以这里的安装次序为 1.httpd 2.Ma ...

  5. FastCGI模式编译安装LAMP+Xcache

    PHP的工作模式:php在lamp环境下共有三种工作模式:CGI模式.apache模块.FastCGI模式.CGI模式下运行PHP,性能不是很好.(已淘汰)FastCGI的方式和apache模块的不同 ...

  6. 二、编译安装LAMP之httpd-2.4.4

    回顾 PHP:脚本编程语言,php解释器 Webapp:面向对象的特性 Zend: 第一段:词法分析.句法分析.编译为Opcode: opcode放置于内存中 第二段:执行opcode: opcode ...

  7. CentOS6.3 编译安装LAMP(1):准备工作

    卸载yum或rpm安装的amp软件 #在编译安装lamp之前,首先先卸载已存在的rpm包. rpm -e httpd rpm -e mysql rpm -e php yum -y remove htt ...

  8. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.2.25

    所需源码包: /usr/local/src/Apache-2.2.25/httpd-2.2.25.tar.gz 编译安装 Apache2.2.25 #切换到源码目录 cd /usr/local/src ...

  9. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.4.6

    Apache官方说: 与Apache 2.2.x相比,Apache 2.4.x提供了很多性能方面的提升,包括支持更大流量.更好地支持云计算.利用更少的内存处理更多的并发等.除此之外,还包括性能提升.内 ...

随机推荐

  1. ubuntu 16.04安装ibus中文输入法

    1. 安装IBus sudo apt-get install ibus-pinyin system settings——>language support——>keyboard input ...

  2. jquery选择器用法

    jquery的基础选择器 选择器的用法其实跟咱们当时讲css的选择器用法类似,只是代码书写的不同 <ul> <li id="brother" class=&quo ...

  3. 初尝微信小程序开发与实践

    这可能是一个java程序员最不务正业的一次分享了. 小程序的火热相信不用我多说了,年初的时候老婆去浦东某达面试,甚至都被问有没有小程序测试经验.俨然小程序成为了互联网公司自PC,WAP,安卓,IOS之 ...

  4. http协议再复习(二)

    HTTP和HTTPS HTTP协议(HyperText Transfer Protocol,超文本传输协议):是一种发布和接收 HTML页面的方法. HTTPS(Hypertext Transfer ...

  5. Java——复制txt文件

    将源文件复制到目标文件,同时输出源文件内容,需要提供一个源文件和目标文件路径参数(如果不存在则自动创建) public static void copyTxt(String sourceFile, S ...

  6. AndroidStudio 中怎样查看获取MD5和SHA1值(应用签名)

    曾经在Eclipse中我们获取MD5和SHA1非常easy就找到了例如以下图所看到的: 就能够在Eclipse中看到所须要调试的MD5和SHA1.可是在AndroidStudio中我找了一圈也没有发现 ...

  7. TCP/IP知识总结(TCP/IP协议族读书笔记一)

    一.简述TCP/IP协议 Transmission Control Protocol/Internet Protocol的简写,即传输控制协议/互联网互联协议,又名网络通信协议.是Internet最基 ...

  8. 初步认识session

    TestSession01.java protected void doPost(HttpServletRequest request, HttpServletResponse response) t ...

  9. lda spark 代码官方文档

    http://spark.apache.org/docs/1.6.1/mllib-clustering.html#latent-dirichlet-allocation-lda http://spar ...

  10. Js And PHP Modify Cookie

    简单的js函数封装cookie //设置cookie function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime ...