htgefwda 发表于 2016-1-15 08:29:32

CentOS 6编译httpd-2.4.10

前提:安装环境:CentOS 6.7apr相关包:apr-1.5.0.tar、apr-util-1.5.3.tarhttpd包:httpd-2.4.10.tar
一、CentOS 6编译httpd-2.4前期配置1.apr: apache portableruntime,apache可移植环境       CentOS 6:上默认:apr-1.3.9,apr-util-1.3.9版本      但是httpd2.4依赖于较新版本的apr,apr-1.4+,apr-util-1.4+, (可选),需编译安装       apr和apr-util版本无需一致2.所需开发环境包组和开发程序包
# yuminstall -y"DevelopmentTools" "Server Platform Development"# yuminstall -ypcre-devel

二、编译安装1.4+版的apr和apr-util1.编译安装apr-1.5.0.tar      # tar xf apr-1.5.0.tar.bz2      # cd apr-1.5.0      [root@localhostapr-1.5.0]# ./configure --prefix=/usr/local/apr      [root@localhostapr-1.5.0]# make -j 4 && make install
2.编译安装apr-util-1.5.3.tar      # tar xf apr-util-1.5.3.tar.bz2      # cd apr-util-1.5.3      [root@localhostapr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with=/usr/local/apr      [root@localhostapr-1.5.0]# make -j 4 && make install注意:编译安装时候要指明所编译需要的安装包,否则会找系统的开发包作为依赖安装包

三、编译启动httpd-2.4服务1.编译httpd-2.4.10.tar         # tar xf httpd-2.4.10.tar.bz2         # cd httpd-2.4.10         # ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24--enable-so --enable-ssl --enable-cgi--enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --enable-modules=most--enable-mpms-shared=all --with-mpm=prefork         # make -j4         # make install安装选项说明:      /usr/local/apache24/build/config.nice:记录了安装时候所执行的命令
--prefix=/usr/local/apache24指定安装路径
--sysconfdir=/etc/httpd24更改定义配置文件的安装路径,不指明就在安装路径下
--enable-so支持DSO机制
--enable-ssl支持ssl功能
--enable-cgi支持cgi机制
--enable-rewrite支持URL重写
--with-zlib依赖于Zlib提供压缩库实现页面压缩
--with-pcre支持pcre扩展的模式,更为强大的正则表达式功能
--with-apr=/usr/local/apr依赖于指定路径的apr
--with-apr-util=/usr/local/apr-util依赖于指定路径的apr-util
--enable-modules=most启用模块,可以给模块列表,可以most大多数常用模块,也可以All
--enable-mpms-shared=all将所有的MPM模块编译出来
--with-mpm=prefork指定启动时默认的MPM模块

2.自带启动脚本:apachectl     (1)方法一:手动指明路径启动         因为编译安装,所以启动服务需指定具体路径:/usr/local/apache24/bin/apachectl start    (2)方法二:更改环境变量直接手动绝对路径             1) # vim /etc/profile.d/httpd.sh                     exportPATH=/usr/local/apache24/bin:$PATH             2) # apachectl start    (3)方法三:开机启动脚本   # cd/etc/rc.d/init.d/   # vimhttpd24   # chkconfig --add httpd24   #service httpd24 start=================================CentOS 6 服务脚本============================================#!/bin/bash## httpd      Startup script for the Apache HTTPServer## chkconfig: - 85 15# description: TheApache HTTP Server is an efficient and extensible\#               server implementing the current HTTPstandards.# 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: TheApache HTTP Server is an extensible server#implementing the current HTTP standards.### END INIT INFO
# Source functionlibrary../etc/rc.d/init.d/functions
if [ -f/etc/sysconfig/httpd ]; then      . /etc/sysconfig/httpdfi
# Start httpd in theC locale by default.HTTPD_LANG=${HTTPD_LANG-"C"}
# This will preventinitlog from swallowing up a pass-phrase prompt if# mod_ssl needs apass-phrase from the user.INITLOG_ARGS=""
# SetHTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with thethread-based "worker" MPM; BE WARNED that some modules may not# work correctlywith a thread-based MPM; notably PHP will refuse to start.
# Path to theapachectl script, server binary, and short-form for messages.apachectl=/usr/local/apache/bin/apachectlhttpd=/usr/local/apache/bin/httpdprog=httpdpidfile=${PIDFILE-/var/run/httpd/httpd24.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd24}RETVAL=0STOP_TIMEOUT=${STOP_TIMEOUT-10}
# The semantics ofthese two functions differ from the way apachectl does# things --attempting to start while running is a failure, and shutdown# when not runningis also a failure.So we just do it theway init scripts# are expected tobehave here.start() {      echo -n $"Starting $prog: "      LANG=$HTTPD_LANG daemon--pidfile=${pidfile} $httpd $OPTIONS      RETVAL=$?      echo      [ $RETVAL = 0 ] && touch${lockfile}      return $RETVAL}
# When stoppinghttpd, a delay (of default 10 second) is required# before SIGKILLingthe httpd parent; this gives enough time for the# httpd parent toSIGKILL any errant children.stop() {echo-n $"Stopping $prog: "killproc-p ${pidfile} -d ${STOP_TIMEOUT} $httpdRETVAL=$?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 toconfiguration syntax error"      failure $"not reloading $httpd dueto 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 werecalled.case "$1"instart)start;;stop)stop;;status)      status -p ${pidfile} $httpdRETVAL=$?;;restart)stopstart;;condrestart|try-restart)ifstatus -p ${pidfile} $httpd >&/dev/null; thenstopstartfi;;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=2esac
exit $RETVAL=====================================================================================================

页: [1]
查看完整版本: CentOS 6编译httpd-2.4.10