httpd-2.4编译安装及新特性详解

简介:

安装环境

  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. 解决依赖关系

    1
    2
    3
    yum -y groupinstall  "Development tools"   # 安装开发包组,包括gcc,automake等
    yum -y groupinstall  "Server Platform Development"  # 安装开发包组
    yum -y  install  pcre-devel  # 兼容Perl的正则表达式库
  3. 编译安装apr-1.5.0

    1
    2
    3
    4
    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

    1
    2
    3
    4
    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编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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模式

后续配置

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

1
2
# vi /etc/httpd249/httpd.conf
PidFile   "/var/run/httpd.pid"

           ii.导出头文件

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

           iii.导出man手册

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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


启动服务并测试

1
2
3
4
5
6
# 为服务脚本赋予执行权限:
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进行










本文转自 xxrenzhe11 51CTO博客,原文链接:http://blog.51cto.com/xxrenzhe/1380704,如需转载请自行联系原作者
目录
相关文章
|
4月前
|
Linux 应用服务中间件 PHP
Linux下搭建PHP环境-源码编译安装PHP7.2
Linux下搭建PHP环境-源码编译安装PHP7.2
153 0
|
4月前
|
Ubuntu 应用服务中间件 PHP
Ubuntu 非手动编译安装 PHP8 和 Nginx
Ubuntu 非手动编译安装 PHP8 和 Nginx
46 0
|
4月前
|
前端开发 JavaScript Shell
centos编译安装PHP(1)
当然,我是直接在服务器上下载的: bash 复制代码
74 1
|
Unix Linux 应用服务中间件
PHP:CentOS Linux环境下源码编译安装PHP8.0
PHP:CentOS Linux环境下源码编译安装PHP8.0
581 0
|
Apache 开发工具 网络安全
|
PHP C语言
CentOS6.9源码编译安装php-memcached扩展
这篇笔记记录了在CentOS6.9源码编译安装libmemcached和php-memcached扩展的过程
9824 0
|
机器学习/深度学习 大数据 Linux
CentOS7.X下安装Gearman-1.1.17及其PHP-7.X扩展
CentOS7.X下安装Gearman-1.1.17及其PHP-7.X扩展
4443 0
|
关系型数据库 MySQL PHP
|
Web App开发 网络安全 Apache