设为首页 收藏本站
查看: 1837|回复: 0

[经验分享] CentOS 6编译httpd-2.4.10

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-15 08:29:32 | 显示全部楼层 |阅读模式
前提:
安装环境:CentOS 6.7
apr相关包:apr-1.5.0.tar  、apr-util-1.5.3.tar
httpd包: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-iconv](可选),需编译安装
       apr和apr-util版本无需一致
  2.所需开发环境包组和开发程序包

  # yum  install -y  "DevelopmentTools" "Server Platform Development"
  # yum  install -y  pcre-devel


二、编译安装1.4+版的apr和apr-util
  1.编译安装apr-1.5.0.tar
      [iyunv@localhosttmp]# tar xf apr-1.5.0.tar.bz2
      [iyunv@localhosttmp]# 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
      [iyunv@localhosttmp]# tar xf apr-util-1.5.3.tar.bz2
      [iyunv@localhosttmp]# 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
         [iyunv@localhosttmp]# tar xf httpd-2.4.10.tar.bz2
         [iyunv@localhosttmp]# cd httpd-2.4.10
         [iyunv@localhosttmp]# ./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
         [iyunv@localhosttmp]# make -j  4
         [iyunv@localhosttmp]# 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/
   # vim  httpd24
   # 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/httpd
fi

# 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/apachectl
httpd=/usr/local/apache/bin/httpd
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd24.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
RETVAL=0
STOP_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} $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 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"in
  start)
start
;;
  stop)
stop
;;
  status)
        status -p ${pidfile} $httpd
RETVAL=$?
;;
  restart)
stop
start
;;
  condrestart|try-restart)
ifstatus -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
=====================================================================================================



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-164563-1-1.html 上篇帖子: Apache 配置虚拟主机 下篇帖子: httpd2.4的新特性、以及基本应用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表