一、 httpd 2.4的新特

1) MPM支持运行时装载
  --enable-mpms-shared=all --with-mpm=prefork|worker|event
2) 支持event MPM
3) 异步读写支持
4) 支持每模块及每目录分别使用不同的日志级别
5) 支持per-request(即支持<If>, <ElseIf>, and <Else>条件判断)
6) 增强版的表达式分析器;
7) 支持毫秒级keepalive timeout;
8) 基于FQDN(域名)的虚拟主机不再需要NameVirtualHost;
9) 支持用户使用自定义变量;
    新增一些模块:mod_proxy_fcgi, mod_ratelimit, mod_request, mod_remoteip
    修改了一些配置机制:不再支持使用order, allow, deny来实现基于IP的访问控制;

二、 系统环境

CentOS6.4 x86_64位 采用最小化安装,系统经过了基本优化  1G内存,1核cpu

selinux为关闭状态,iptables关闭状态

三、编译准备

    1. 安装相关依赖工具

  # yum  install -y gcc gcc-c++ wget expat-devel zlib-devel zlib openssl openssl-devel libxml2-devel

2. 下载相关软件包

# wget http://www-us.apache.org/dist//httpd/httpd-2.4.37.tar.gz

# wget -c http://www-us.apache.org/dist//apr/apr-1.6.5.tar.gz

# wget -c http://www-us.apache.org/dist//apr/apr-util-1.6.1.tar.gz

# wget https://ftp.pcre.org/pub/pcre/pcre-8.32.tar.gz

     3. 编译安装依赖包

# cd /usr/local/src

安装apr:

  # tar xf apr-1.6.5.tar.gz

   # cd  apr-1.6.5

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

   # make && make install

   安装apr-util:

  # tar xf apr-util-1.6.1.tar.gz

   # cd  apr-util-1.6.1

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

   # make && make install

安装pcre:

  # tar -xf pcre-8.32.tar.gz

   # cd pcre-8.32

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

   # make && make install

        注意:如果你下载pcre2的话,apache2.4会出现编译不通过,建议不要使用pcre2.

四、编译安装httpd

# tar -xf httpd-2.4.37.tar.gz

# cd httpd-2.4.37

开始配置:

./configure \
--prefix=/usr/local/httpd24 \
--sysconfdir=/etc/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--enable-deflate \
--enable-expires \
--with-pcre=/usr/local/pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-mods-shared=most \
--enable-mpms-shared=all \
--with-mpm=prefork/event/worker

注意:如果是复制粘贴配置,要注意每行结尾\之前只能有一个空格,之后不能有空格

参数含义:

./configure \
--prefix=/usr/local/httpd24 \                 # 指定安装路径
--sysconfdir=/etc/httpd24 \                  # 指定配置文件路径
--enable-so \                # 启用动态模块加载
--enable-ssl \             # 启用ssl加密传输
--enable-cgi \                                       # 允许使用cgi脚本
--enable-rewrite \                                 # 启用url重写功能
--with-zlib \                                           # 支持数据包压缩
--enable-deflate \                                 # 支持网页压缩
--enable-expires \                                # 支持网页缓存
--with-pcre=/usr/local/pcre \                 # pcre安装路径
--with-apr=/usr/local/apr \                     # apr安装路径
--with-apr-util=/usr/local/apr-util \          #  apr-util 安装路径
--enable-mods-shared=most \              # 动态的编译进来大多数的模块
--enable-mpms-shared=all \                  # 动态编译MPM所有支持的模式 
--with-mpm=prefork/event/worker         # 默认加载使用的mpm

编译并安装:

# make && make install

五、安装后配置

1. 将apache二进制程序目录加入环境变量PATH

    # echo 'export PATH=/usr/local/http24/bin:$PATH' >>/etc/profile

    # source  /etc/profile

   2. 链接方式输出头文件

    # ln -sv /usr/local/httpd24/include /usr/include/apache

   3. 添加man帮助手册

    编辑man.config文件,找到 MANPATH /usr/X11R6/man 这一行,在下面添加如下一行

    MANPATH /usr/local/httpd24/man

    4.添加启动脚本

    a. 系统自带脚本

     # cp /usr/local/httpd24/bin/apachectl /etc/init.d/httpd

    vi打开,添加两行   

    # chkconfig: 35 85 15
    # description: The Apache HTTP Server

      b. 相关启动脚本

#!/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/httpd.conf

# pidfile: /usr/local/httpd24/logs/httpd.pid

#

### BEGIN INIT INFO

# Provides: httpd

# Required-Start: $local_fs $remote_fs $network $named

# Required-Stop: $local_fs $remote_fs $network

# Should-Start: distcache

# Short-Description: start and stop Apache HTTP Server

# Description: The Apache HTTP Server is an extensible server

#  implementing the current HTTP standards.

### END INIT INFO

# Source function library.

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

if [ -f /etc/httpd ]; then

. /etc/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=""

# Path to the apachectl script, server binary, and short-form for messages.

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

httpd=/usr/local/httpd24/bin/httpd

prog=httpd

pidfile=${PIDFILE-/usr/local/httpd24/logs/httpd.pid}

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

RETVAL=0

STOP_TIMEOUT=${STOP_TIMEOUT-10}

# The semantics of these two functions differ from the way apachectl does

# things -- attempting to start while running is a failure, and shutdown

# when not running is also a failure.  So we just do it the way init scripts

# are expected to behave here.

start() {

echo -n $"Starting $prog: "

LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch ${lockfile}

return $RETVAL

}

# When stopping httpd, a delay (of default 10 second) is required

# before SIGKILLing the httpd parent; this gives enough time for the

# httpd parent to SIGKILL any errant children.

stop() {

status -p ${pidfile} $httpd > /dev/null

if [[ $? = 0 ]]; then

echo -n $"Stopping $prog: "

killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd

else

echo -n $"Stopping $prog: "

success

fi

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)

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

c. 开机启动httpd服务

# chkconfig --add httpd

# chkconfig httpd on

# chkconfig --list httpd

    5. 测试安装

   打开浏览器,在浏览器输入centos主机的ip地址,或者本机curl,检测安装是否成功。

# curl localhost

<html><body><h1>It works!</h1></body></html>

六、可能遇到的问题

    1. 启动报错

启动时会出现“AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName’ directive globally to suppress this message”这样的报错,只需要编辑http.conf文件,找到#ServerName www.example.com:80这一行,在下面添加 如下一行,然后重启apache

    # vim /etc/httpd/httpd.conf

ServerName localhost:80

取消以下注释行,开启httpd状态监控

Include /etc/httpd24/extra/httpd-info.conf

2.

  参数方面没问题,然后我开始一个个去掉参数:发现问题出现在--enable-cgi \这个上面,故这个有问题。
  最后对调参数,参数放在倒数第二个再次环境测试!结果发现通过了!,其实问题出现在\后面有空格,去掉空格再编译

3. 

这个提示是openssh版本太低,yum install -y openssl openssl-devel 解决

  4.

  

    

缺少了xml相关的库,需要安装libxml2-devel包。直接安装并不能解决问题,因为httpd调用的apr-util已经安装好了,但是apr-util并没有libxml2-devel包支持。

安装libxml2-devel包

[root@localhost ~]# yum install -y libxml2-devel

删除apr-util安装目录,并重新编译安装

[root@localhost ~]# rm -rf /usr/local/apr-util
[root@localhost ~]# cd /usr/local/src/apr-util-1.6.1 # 这一步很重要,必须清除之前配置时的缓存
[root@localhost apr-util-1.6.1]# make clean # 源码安装三步走
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install

重新编译安装httpd

# 同样要清理之前的缓存十分重要
[root@localhost src]# cd /usr/local/src/httpd-2.4.28
[root@localhost httpd-2.4.28]# make clean
[root@localhost httpd-2.4.28]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@localhost httpd-2.4.28]# make
# 这时make没报错了 [root@localhost httpd-2.4.28]# make install
注:此处参考http://blog.51cto.com/castiel/2051440

CentOS 6.5 编译安装Apache2.4的更多相关文章

  1. 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 ...

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

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

  3. centos6.3编译安装Apache2.4.3+PHP5.4.8+Mysql5.5.8

    以虚拟机VirtualBox 版本是4.1.20(内存设置为512M,centos安装是文本模式下安装),全新以最小化包安装了32位的 CentOS6.3系统,作为本地web环境,上次讲了在windo ...

  4. CentOS 6.8编译安装httpd2.2.31+MySQL5.6.31+PHP5.3.27

    CentOS 6.8编译安装httpd2.2.31+MySQL5.6.31+PHP5.3.27   说明:   操作系统:CentOS 6.8 32位 准备篇: 一.系统约定    软件源代码包存放位 ...

  5. Ubuntu 16.04下编译安装Apache2.4和PHP7结合

    Ubuntu 16.04下编译安装Apache2.4和PHP7结合,并安装PDOmysql扩展. 1.编译安装apache2.4.20 1 第一步: ./configure --prefix=/usr ...

  6. CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14

    准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7. ...

  7. centos 7.0 编译安装php 7.0.3

    php下载页面 http://cn2.php.net/downloads.php 7.0.3多地区下载页面 http://cn2.php.net/get/php-7.0.3.tar.gz/from/a ...

  8. CentOS 6.6编译安装Nginx1.6.2+MySQL5.6.21+PHP5.6.3

    http://www.osyunwei.com/archives/8867.html 一.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables #编辑防火墙配置 ...

  9. CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13

    CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好I ...

随机推荐

  1. 安装Python包报错——ReadTimeoutError

    一.问题:安装python包的时候报错ReadTimeoutError——Read time out. 二.解决办法三种方法,一是切换下载源:二是下载相应平台的安装包后安装:三是下载源码编译安装:  ...

  2. squid代理简介

    squid代理 简单介绍一下正向代理和反向代理 标准代理:缓存静态页面,但是要实现这种方式必须在内部主机的浏览器内指明代理服务址和端口. 透明代理:不需要指明代理服务器的IP和端口 二)反向代理 可以 ...

  3. Python深入:编码问题总结

    转自:http://blog.csdn.net/gqtcgq/article/details/47068817 一:字符编码简介          1:ASCII          最初的计算机的使用 ...

  4. spring boot 2.0(三)使用docker部署springboot

    Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下. 首先构建一个简单的 Spring Boot 项目, ...

  5. HDU-3605-Escape(最大流, 状态压缩)

    链接: https://vjudge.net/problem/HDU-3605 题意: 2012 If this is the end of the world how to do? I do not ...

  6. electron-vue 更新 使用electron-update的版本

    electron-vue使用的electron版本比较老,用最新的electron-update会报错 我用这个版本成功 "electron-updater": "^3. ...

  7. 【leetcode】LCP 3. Programmable Robot

    题目如下: 力扣团队买了一个可编程机器人,机器人初始位置在原点(0, 0).小伙伴事先给机器人输入一串指令command,机器人就会无限循环这条指令的步骤进行移动.指令有两种: U: 向y轴正方向移动 ...

  8. 对云信SDK的研究1

    1.云信大部分用了jq 2.很多接口 3.是可以文档很健全

  9. Linux的解压缩相关命令

    Linux的解压缩相关命令 知识点: 1.zip命令 2.tar命令 3.压缩和解压常用组合

  10. F12谷歌开发者工具preserve log

    谷歌开发者工具里面这个preserve log :保留请求日志,跳转页面的时候勾选上,可以看到跳转前的请求,也可适用于chrome开发者工具抓包的问题