码迷,mamicode.com
首页 > 其他好文 > 详细

httpd-2.4 编译安装

时间:2014-05-05 22:02:02      阅读:346      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   code   java   

安装环境

  1. 系统环境:CentOS 6.5-x86_64

  2. 所需软件包:

    1. apr-1.5.0.tar.bz2

    2. apr-util-1.5.3.tar.bz2

    3. httpd-2.4.9.tar.bz2

  3. 下载地址:

    1. http://apr.apache.org/ 

    2. http://httpd.apache.org/

 

安装步骤

  1. 注:httpd-2.4版本依赖于更高版本(1.5版本以上)的apr和apr-util;apr全称为apache portable runtime,能实现httpd跨平台运行

  2. 解决依赖关系

    tar xf apr-util-1.5.3.tar.bz2
    cd apr-util-1.5.3
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
    make && make install
  3. 编译安装apr-1.5.0

    tar xf apr-1.5.0.tar.bz2
    cd apr-1.5.0
    ./configure --prefix=/usr/local/apr
    make && make install
  4. 编译安装apr-util-1.5.3

    tar xf apr-util-1.5.3.tar.bz2
    cd apr-util-1.5.3
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
    make && make install
  5. httpd编译安装

bubuko.com,布布扣
tar xf httpd-2.4.9.tar.bz2
cd httpd-2.4.9
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd249 --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-deflate --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
make && make install
# 各编译参数详解
--prefix:#安装路径
--sysconfdir:#指定配置文件路径
--enable-so:#DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效
--enable-ssl:#支持SSL/TLS,可以实现https访问
--enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启)
--enable-rewrite:#启用Rewrite功能
--enable-deflate:#支持压缩
--with-z:#使用指定的zlib库,不指定路径会自动寻找
--with-pcre:#使用指定的PCRE库,不指定路径会自动寻找
--with-apr:#指定apr安装路径
--with-apr-util:#指定apr-util安装路径
--enable-modules:#支持动态启用的模块,可选参数有“all”,“most”,“few”,“reallyall”
--enable-mpms-shared:#支持动态加载的MPM模块,可选“all”
--with-mpm:#设置默认启用的MPM模式
bubuko.com,布布扣

后续配置

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

ln -sv /usr/local/apache/include /usr/include/httpd

ii.导出头文件

ln -sv /usr/local/apache/include /usr/include/httpd

iii.导出man手册

vi /etc/man.config
    MANPATH /usr/local/apache/man  # man文件在apache安装目录下哦

iv.编写服务脚本(因是编译安装,不会自动生成服务脚本)

bubuko.com,布布扣
# vi /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
bubuko.com,布布扣

启动服务并测试

# 为服务脚本赋予执行权限:
chmod +x /etc/rc.d/init.d/httpd
# 加入服务列表:
chkconfig --add httpd
# 启动服务
service httpd start

浏览器访问:http://Server_IP/   # 显示“It works”,即表示httpd服务启动成功

 

httpd 2.4新特性说明

  1. 新增特性

    1. MPM支持在运行时装载

    2. 支持event MPM类型

    3. 支持异步读写

    4. 在每模块及每目录上指定日志级别

    5. 每请求配置:<If>,<Elseif>

    6. 增强版的表达式分析器

    7. 毫秒级的keepalive timeout

    8. 基于FQDN的虚拟主机不再需要NameVirtualHost指令

    9. 支持使用自定义变量

  2. 新增模块

    1. mod_proxy_fcgi

    2. mod_ratelimit

    3. mod_request

    4. mod_remoteip

  3. 修改

    1. 对于基于IP的访问控制做了修改,不再支持使用order, allow, deny这些机制,而是统一使用require进行

httpd-2.4 编译安装,布布扣,bubuko.com

httpd-2.4 编译安装

标签:des   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/xiaocen/p/3704864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!