httpd-2.4的安装
实验环境为centOS6.5,由于centOS6上的库文件及开发工具等不适合安装httpd-2.4,所以需要手动安装这两个包apr和apr-util,httpd-2.4依赖1.4版本以上的apr和apr-util。下面简单介绍一下apr。
apr简介
apr(apache portable runtime),即apache的可移植运行环境,由于底层环境的不同,apache应用程序需要根据不同的平台来开发,而apr消除了底层平台的差异,apr能够为大多数的平台提供所有的apr特性支持,包括BeOS,UNIX,Linux等等,apr为这些大部分的平台提供了一个公共的统一操作函数接口,使得不同平台上的apache应用程序执行的接口基本都是统一一致的。
编译安装
下载源码包
-rw-r--r-- 1 root root 813976 Jul 1 09:09 apr-1.5.0.tar.bz2 -rw-r--r-- 1 root root 695303 Jul 1 09:09 apr-util-1.5.3.tar.bz2 -rw-r--r-- 1 root root 4994460 Jul 1 09:09 httpd-2.4.9.tar.bz2
1)编译安装apr-1.5.0
[root@www ~]# tar xf apr-1.5.0.tar.bz2 [root@www ~]# cd apr-1.5.0 [root@www apr-1.5.0]# ./configure --prefix=/usr/local/apr-1.5.0 checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Configuring APR library ............. [root@www apr-1.5.0]# make && make install
2)编译安装apr-util-1.5.3
[root@www ~]# tar xf apr-util-1.5.3.tar.bz2 [root@www ~]# cd apr-util-1.5.3 [root@www apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util-1.5.3/ --with-apr=/usr/local/apr-1.5.0/ checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking for working mkdir -p... yes .............. [root@www apr-util-1.5.3]# make && make install
由于apr-util依赖apr所以在安装apr-util时需要通过“--with-apr”指定已安装的apr。
2)编译安装httpd-2.4.9
[root@www ~]# tar xf httpd-2.4.9.tar.bz2 [root@www ~]# cd httpd-2.4.9 [root@www httpd-2.4.9]# ./configure --prefix=/usr/local/apache2.4.9 --sysconfdir=/etc/http d --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/ usr/local/apr-1.5.0 --with-apr-util=/usr/local/apr-util-1.5.3 --enable-mpms-shared=all --with -mpm=event --enable-modules=most ........... [root@www httpd-2.4.9]# make && make install
简单介绍一下涉及到的各参数:
--prefix=/usr/local/apache2.4.9 #应用程序安装路径
--sysconfdir=/etc/httpd #配置文件的安装路径
--enable-so #支持DSO动态装载模块
--enable-ssl #要编译启用ssl模块(前提是需要安装openssl-devel)
--enable-cgi #启用CGI模块(默认就启用)
--enable-rewrite #URL重写(把用户访问的URL由服务器自动的改成另外一个URL,这是一个非常有
#用的机制)
--with-zlib #这是一个压缩库(专用于网络传输)
--with-pcre #使用增强的perl正则表达式分析工具(使用这项需要安装pcre-devel,pcre:
#正则表达式分析器)
--with-apr=/usr/local/apr #指明apr的目录(若apr在特殊路径下)
--with-apr-util=/usr/local/apr-util/ #指明apr-util路径(若apr-util在特殊路径下)
--enable-mpms-shared=all #把所有的mpm模块都编译进来而且是共享模块
--with-mpm=event #默认使用的mpm模块
--enable-modules=most|all #还有很多其他模块,其他的动态可装载模块需要编译哪些
#(all:所有都编译,most:编译一些常用的模块)
[root@www profile.d]# vim /etc/profile.d/apache.sh export PATH=/usr/local/apache2.4.9/bin:$PATH [root@www profile.d]# . /etc/profile.d/apache.sh
将apache应用程序bin目录添加到path环境变量中。由于是编译安装,所以在/etc/init.d目录下没有对应的脚本文件,需要自己编写,就不编写了,直接将rpm包安装后自动生成的脚本文件httpd复制过来吧,改一下其中的几个参数。
#!/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/apache2.4.9/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/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/apache2.4.9/bin/apachectl
httpd=${HTTPD-/usr/local/apache2.4.9/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache2.4.9/logs/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 $RETVALapachectl=/usr/local/apache2.4.9/bin/apachectl
httpd=${HTTPD-/usr/local/apache2.4.9/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache2.4.9/logs/httpd.pid}
修改了上面几个参数,这里编译安装的应用程序将pidfile放置在/usr/local/apache2.4.9/logs/,可以通过在主配置文件中通过PidFile参数修改pid文件的放置位置。
PidFile "/var/run/httpd/httpd.pid"
[root@www bin]# chkconfig --add /etc/init.d/httpd [root@www bin]# chkconfig --list httpd httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
启动服务
[root@www logs]# service httpd start Starting httpd: [ OK ] [root@www logs]# ss -tuln | grep 80 tcp LISTEN 0 128 :::80 :::*
ok......
目录介绍
mpm模块介绍
原文地址:http://ljbaby.blog.51cto.com/10002758/1669905