httpd2.4
新特性:

  1. MPM支持运行为DSO机制;以模块形式按需加载
  2. event MPM生产环境可用
  3. 异步读写机制
  4. 支持每模块及每目录的单独日志级别定义
  5. 每请求相关的专用配置
  6. 增强版的表达式分析式
  7. 毫秒级持久连接时长定义
  8. 基于FQDN的虚拟主机也不在需要NameVirutailHost指令
  9. 新指令,AllowOverrideList
  10. 支持用户自定义变量
  11. 更低的内存消耗
    新模块:
    1. mod_proxy_fcgi:支持PHP
    2. mod_proxy_scgi:支持python
    3. mode_remoteip
      安装httpd2.4
      依赖apr:apache protable runtime,apache可移植运行环境
      依赖pcre:Per Compatible Regular Expressions,中文含义perl语言兼容正则表达式是一个用c语言编写的正则表达式函数库,pcre被广泛使用在许多开源软件之中,最著名的莫过于Apache HTTP服务器和PHP脚本语言、R脚本语言,此外,正如从其名字所能看到的,pcre也是perl语言的缺省正则库

实验环境:

[root@Centos7 data]# uname -r
3.10.0-693.el7.x86_64
[root@Centos7 data]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

[root@Centos7 data]# ls
httpd-2.4.25.tar.bz2

查看本机是否有安装httpd,如有请卸载

[root@Centos7 data]# rpm -q httpd
package httpd is not installed

源码编译安装httpd之前,先使用yum安装相关依赖包

[root@Centos7 data]# yum -y install gcc openssl-devel pcre-devel apr-devel apr-util-devel

创建一个目录专门用于管理源码编译的程序/apps

[root@Centos7 data]# mkdir /apps

解包httpd-2.4.25.tar.bz2

[root@Centos7 data]# tar xf httpd-2.4.25.tar.bz2 
[root@Centos7 data]# ls
httpd-2.4.25  httpd-2.4.25.tar.bz2
[root@Centos7 data]# cd httpd-2.4.25/
[root@Centos7 httpd-2.4.25]# ls
ABOUT_APACHE     BuildAll.dsp    configure.in  include         LICENSE        README            test
acinclude.m4     BuildBin.dsp    docs          INSTALL         Makefile.in    README.cmake      VERSIONING
Apache-apr2.dsw  buildconf       emacs-style   InstallBin.dsp  Makefile.win   README.platforms
Apache.dsw       CHANGES         httpd.dep     LAYOUT          modules        ROADMAP
apache_probes.d  CMakeLists.txt  httpd.dsp     libhttpd.dep    NOTICE         server
ap.d             config.layout   httpd.mak     libhttpd.dsp    NWGNUmakefile  srclib
build            configure       httpd.spec    libhttpd.mak    os             support

通过查看INSTALL文件,就基本能知道该如何去编译安装httpd
由于是简易的源码编译安装httpd,所以只需要指定一些简单的选项即可
编译安装三大步:
1、./configure
2、make
3、make install

[root@Centos7 httpd-2.4.25]# ./configure \
> --prefix=/apps/httpd24 \          #安装路径
> --sysconfdir=/etc/httpd \         #配置文件路径
> --enable-ssl \                          #启动ssl加密功能
> --enable-so                             #启动共享库

configure: summary of build options:

    Server Version: 2.4.25
    Install prefix: /apps/httpd24
    C compiler:     gcc -std=gnu99
    CFLAGS:           -pthread
    LDFLAGS:         
    LIBS:           
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    C preprocessor: gcc -E

[root@Centos7 httpd-2.4.25]# make && make install
...
Installing man pages and online manual
mkdir /apps/httpd24/man
mkdir /apps/httpd24/man/man1
mkdir /apps/httpd24/man/man8
mkdir /apps/httpd24/manual
make[1]: Leaving directory `/data/httpd-2.4.25'

设定PATH路径

[root@Centos7 httpd-2.4.25]# cd /apps/
[root@Centos7 apps]# ls
httpd24
[root@Centos7 apps]# ls httpd24/bin/
ab         apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
apachectl  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
[root@Centos7 apps]# cd httpd24/bin/
[root@Centos7 bin]# pwd
/apps/httpd24/bin

[root@Centos7 bin]# echo "PATH=/apps/httpd24/bin:$PATH" > /etc/profile.d/httpd.sh
[root@Centos7 bin]# . /etc/profile.d/httpd.sh

启动httpd24服务,访问主页

[root@Centos7 bin]# cd
[root@Centos7 ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Centos7.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@Centos7 ~]# ss -tn
State      Recv-Q Send-Q            Local Address:Port                           Peer Address:Port              
ESTAB      0      0                    10.0.17.93:22                               10.0.16.89:49385              
[root@Centos7 ~]# ss -tnl
State      Recv-Q Send-Q            Local Address:Port                           Peer Address:Port              
LISTEN     0      128                           *:111                                       *:*                  
LISTEN     0      5                 192.168.122.1:53                                        *:*                  
LISTEN     0      128                           *:22                                        *:*                  
LISTEN     0      128                   127.0.0.1:631                                       *:*                  
LISTEN     0      100                   127.0.0.1:25                                        *:*                  
LISTEN     0      128                          :::111                                      :::*                  
LISTEN     0      128                          :::80                                       :::*                  
LISTEN     0      128                          :::22                                       :::*                  
LISTEN     0      128                         ::1:631                                      :::*                  
LISTEN     0      100                         ::1:25                                       :::*                  
[root@Centos7 ~]# curl http://localhost

It works!

如果想开机启动,可以把apachectl start写入到/etc/rc.local 文件里