阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

编译安装最新版httpd-2.4

125次阅读
没有评论

共计 5307 个字符,预计需要花费 14 分钟才能阅读完成。

新版本的 httpd-2.4 新增以下特性;
新增模块;
mod_proxy_fcgi(可提供 fcgi 代理)
mod_ratelimit(限制用户带宽)
mod_request(请求模块,对请求做过滤)
mod_remoteip(匹配客户端的 IP 地址)
对于基于 IP 的访问控制做了修改,不再支持 allow,deny,order 机制,而是统一使用 require 进行

CentOS 6.5 编译安装 httpd-2.4.7  http://www.linuxidc.com/Linux/2014-02/97265.htm

还新增以下几条新特性;

1、MPM 支持在运行时装载; 不过要开启这种特性,在编译安装要启用这三种功能;
–enable-mpms-shared=all  –with-mpm=event
2、支持 event
3、支持异步读写
4、在每个模块及每个目录上指定日志级别
5、增强版的表达式分析器
6、每请求配置:<If>, <Elseif>
7、毫秒级别的 keepalive timeout
8、基于 FQDN 的虚拟主机不再需要 NameVirtualHost 指令
9、支持使用自定义变量

一;准备环境

Centos6.5-64 位

安装 httpd 前需准备的程序包组;这几个程序包系统自带光盘就有,只需挂载到指定目录,制作成本地 yum 源即可安装使用。(此处不做过多介绍)

解决依赖关系

yum groupinstall -y “Server Platform Development”

yum groupinstall -y “Development tools”

yum install -y pcre-devel-7.8-6.el6.x86_64

二;编译安装 httpd2.4 所依赖的软件包

httpd2.4 依赖于更高版本的 apr 和 apr-util,apr 全称为 apache portable runtime(apache 可运行时移值)。它是个能够让 Apache 跨平台工作的工具,是个底层库,安装上 apr 后。如果在 win 和 linux 上安装上 apr 后,Apache 的同一个代码,即可以在 win 上运行也可在 linux 上运行;

1. 安装 apr-1.5.0.tar.bz2

wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.bz2

[root@www xf]# tar xf ^Cr-1.5.0.tar.bz2

[root@www xf]# cd apr-1.5.0

[root@www apr-1.5.0]# ./configure –prefix=/usr/local/apr

[root@www apr-1.5.0]# make && make install

2. 安装 apr-util-1.5.3

ftp://ftp.mirrorservice.org/sites/ftp.apache.org/apr/apr-util-1.5.3.tar.bz2

[root@www xf]# tar xf apr-util-1.5.3.tar.bz2

[root@www xf]# cd apr-util-1.5.3

[root@www apr-util-1.5.3]# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/

[root@www apr-util-1.5.3]# make && make install

3. 以上两步编译完成,现正式开始编译 httpd-2.4.9.tar.bz2

http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.9.tar.bz2

[root@www xf]# tar xf httpd-2.4.9.tar.bz2

[root@www xf]# cd httpd-2.4.9

[root@www httpd-2.4.9]# ./configure –prefix=/usr/local/apache –sysconfdir=/etc/httpd24 –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-modules=most –enable-mpms-shared=all –with-mpm=event

–prefix=/usr/local/apache 安装路径

–sysconfdir=/etc/httpd24 配置文件路径

–enable-so 允许运行时加载 DSO 模块

–enable-ssl 如果不加载将无法使用使用 https

–enable-cgi 允许使用 cgi 脚本

–enable-rewrite 支持 URL 重写机制

–with-zlib 支持网络通用压缩库

–with-pcre 支持 pcre

–with-apr=/usr/local/apr 指定 apr 的安装路径

–with-apr-util=/usr/local/apr-util/ 指定 apr-util 的安装路径

–enable-modules=most 启用大多数常用的模块

–enable-mpms-shared=all 启用 MPM 所有支持的模式

–with-mpm=event 默认使用 enevt 模式

查看安装后所生成的文件 extra 目录是 2.4 版新增目录

[root@www httpd24]# ls

extra  httpd.conf  magic  mime.types  original

[root@www httpd24]# cd extra/

[root@www extra]# ls

httpd-autoindex.conf  httpd-info.conf      httpd-mpm.conf                httpd-userdir.conf

httpd-dav.conf        httpd-languages.conf  httpd-multilang-errordoc.conf  httpd-vhosts.conf

httpd-default.conf    httpd-manual.conf    httpd-ssl.conf                proxy-html.conf

三、安装后所需配置;

    1、导出头文件;以目录链接的形式来实现

[root@station154 ~]# ln -sv /usr/local/apache/include/ /usr/include/httpd

`/usr/include/httpd’ -> `/usr/local/apache/include/’

2、输出二进制程序

root@station154 ~]# vim /etc/profile.d/httpd24.sh

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

root@station154 ~]#. /etc/profile.d/httpd24.sh

[root@www ~]# httpd -V    显示 httpd 版本信息

3、导出 man 文件

[root@www ~]# vim /etc/man.config

MANPATH /usr/local/apache/man

[root@www ~]# man -M /usr/local/apache/man httpd

4、启动 httpd

[root@www ~]# apachectl start

[root@www ~]# ss -tunl | grep 80

tcp    LISTEN    0      128                  :::80                  :::*

 5、修改服务脚本;

      修改服务前先把 httpd 关闭;apachect1 stop

vim /etc/init.d/httpd24.sh

#!/bin/bash

#

# httpd        Startup script for the Apache HTTP Server

#

# chkconfig: – 85 15

# description: The Apache HTTP Server is an efficient and extensible  \

#              server implementing the current HTTP standards.

# processname: httpd

# config: /etc/httpd/conf/httpd.conf

# config: /etc/sysconfig/httpd

# pidfile: /var/run/httpd/httpd.pid

. /etc/rc.d/init.d/functions

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

        . /etc/sysconfig/httpd

fi

HTTPD_LANG=${HTTPD_LANG-“C”}

INITLOG_ARGS=””

apachectl=/usr/local/httpd24/bin/apachectl

httpd=/usr/local/apache/bin/httpd

prog=httpd

pidfile=${PIDFILE-/var/run/httpd24.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

RETVAL=0

STOP_TIMEOUT=${STOP_TIMEOUT-10}

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 ${STOP_TIMEOUT} $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=6

        echo $”not reloading due to configuration syntax error”

        failure $”not reloading $httpd due to configuration syntax error”

    else

        # Force LSB behaviour from killproc

        LSB=1 killproc -p ${pidfile} $httpd -HUP

        RETVAL=$?

        if [$RETVAL -eq 7]; then

            failure $”httpd shutdown”

        fi

    fi

    echo

}

# See how we were called.

case “$1” in

  start)

        start

        ;;

  stop)

  status)

        status -p ${pidfile} $httpd

        RETVAL=$?

        ;;

  restart)

        stop

        start

        ;;

  condrestart|try-restart)

        if status -p ${pidfile} $httpd >&/dev/null; then

                stop

                start

        fi

        ;;

  force-reload|reload)

        reload

        ;;

  graceful|help|configtest|fullstatus)

        $apachectl $@

        RETVAL=$?

        ;;

  *)

        echo $”Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}”

        RETVAL=2

esac

exit $RETVAL

现在可以利用脚本来启动 httpd 服务

[root@www ~]# service httpd24 restart

Stopping httpd:                                            [OK]

Starting httpd:                                            [OK]

[root@www ~]# elinks -dump www.linuxidc.com/index.html  elinks 测试启动

                                  It works!

下篇将介绍 httpd2.4 基本功能的实现 … http://www.linuxidc.com/Linux/2014-03/98762.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计5307字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中