httpd2.4之编译安装及配置参数详细说明

时间:2022-06-28 12:57:46

一,安装环境描述

   VMware workstation 10,CentOS 6.5 64位,强烈建议系统中事先安装开始工具包“Development Tools”,以免在编译安装httpd软件是出现错误(介绍就这么多, Let's go....^_^)

二,httpd新性性介绍

           1,MPM支持在运行时动态装载(Multipath Process Module)

           2,支持event
           3,异步读写
           4,在每模块及每目录上指定日志级别,日志粒度更细
           5,每请求配置:<If>,<Elseif>
           6,增强版的表达式分析器
           7,毫秒级的keepalive timeout,2.2版本的为秒级别的keepalive timeout
           8,基于FQDN的虚拟主机不再需要NameVirtualHost指令
           9,支持使用自定义变量
           新增的模块,mod_proxy_fcgi,mod_ratelimit,mod_request,mod_remoteIP
           对于基于IP的访问控制做了修改,不再支持使用order allow,deny这些机制,而是统一使用require进行

三,具体的安装与配置

   httpd2.4版本更高版本的apr及apr-util具体相关的包下载地址为:

   apr-1.5.0下载地址:http://mirror.bit.edu.cn/apache//apr/apr-1.5.0.tar.bz2

   apr-util-1.5.3下载地址:http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.3.tar.bz2

   httpd-2.4.9下载地址:http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.9.tar.bz2

   1,编译解压安装apr

       1)编译配置安装路径

httpd2.4之编译安装及配置参数详细说明


       2)编译及安装

httpd2.4之编译安装及配置参数详细说明

       3)安装成功并查看安装文件

httpd2.4之编译安装及配置参数详细说明


2,解压配置编译安装apr-tuil包

       1)配置安装路httpd2.4之编译安装及配置参数详细说明

       2)编译及安装

httpd2.4之编译安装及配置参数详细说明

       3)安装成功及查看安装文件

httpd2.4之编译安装及配置参数详细说明


httpd2.4之编译安装及配置参数详细说明

3,配置编译安装httpd-2.4.9

       1)配置安装路径及指定相关参数httpd2.4之编译安装及配置参数详细说明

       2)编译及安装

httpd2.4之编译安装及配置参数详细说明

       3)安装成功及查看安装路径文件

httpd2.4之编译安装及配置参数详细说明


       4)配置httpd头文件链接地址方便其它程序编译安装时使用   httpd2.4之编译安装及配置参数详细说明

       5)停止之前rpm包安装的httpd软件,如果没有安装可以忽略此步骤

httpd2.4之编译安装及配置参数详细说明

       6)修改服务启动脚本
httpd2.4之编译安装及配置参数详细说明

#!/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
#
### 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/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/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
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() {
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)
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

       7)修改/etc/httpd/httpd.conf为配置启动脚本做准备  

httpd2.4之编译安装及配置参数详细说明


       8)增加httpd可执行文件的查找路httpd2.4之编译安装及配置参数详细说明

       9)启动服务及查看安装httpd的安装版本


httpd2.4之编译安装及配置参数详细说明

       10)查看默认加载的模块信息

httpd2.4之编译安装及配置参数详细说明

       11)打开浏览器查看是否安装成功,如下图所示

httpd2.4之编译安装及配置参数详细说明

   至此,httpd-2.4.9已经安装成功

四,配置文件参数解析与配置(/etc/httpd/httpd.conf,/etc/httpd/extra/httpd-vhosts.conf)

文件/etc/httpd/httpd.conf部分

   1,默认端口的配置与修改

文件/etc/httpd/extra/httpd-vhosts.conf部分

五,HTTPS配置样例参考与实现

六,LAMP编译安装实现(memcache)

七,LAMP编译安装实现(fastCGI/php-fpm)