zoukankan      html  css  js  c++  java
  • 编译安装httpd-2.4

    首先要准备好环境,然后下载httpd-2.4.25.tar的包(http://httpd.apache.org)

    1:安装包组

    # yum groupinstall -y "Development tools" "Server Platform Development"

    2:安装依赖包

    # yum install -y pcre-devel apr-devel apr-util-devel openssl-devel

    3:解压本地的httpd-2.4.25.tar

    # tar xf httpd-2.4.25.tar

    # cd httpd-2.4.25

    4:配置安装信息,生成make file,yum安装的rpm包一般都是在/usr目录下

    # ./configure --prefix=/usr/local/apache-2.4 --sysconfdir=/etc/httpd-2.4 --enable-so --enable-ssl --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-zlib --with-pcre --with-apr=/usr --with-apr-util=/usr --with-mpm=prefork

    5:编译安装

    # make && make install

    6:制作链接,便于版本管控

    # ln -sv /usr/local/apache-2.4 /usr/local/apache

    7:因为自带的Apache服务控制脚本:Apachectl 脚本在/usr/local/apache-2.4/bin/目录下,可以将这个目录加到环境变量中,编辑vi /etc/profile.d/httpd.sh ,添加export PATA=/usr/local/apache/bin/:$PATH,那么启动的时候就可以直接使用apachectl start

    # vi /etc/profile.d/httpd.sh

    export PATA=/usr/local/apache/bin/:$PATH

    # ./etc/profile.d/httpd.sh

    8:将头文件和库文件输出到默认的

    # ln -sv /usr/apache/include /usr/include/httpd

    9:启动httpd-2.4

    # apachectl start 

    10:编写服务脚本实现 server httpd start 启动httpd(从这里开始一下都可可以不用写)

    # vi /etc/rc.d/init.d/functions

     

    #! /bin/bash
    #
    # network Bring up/down networking
    #
    # chkconfig: 2345 10 90
    # description: Activates/Deactivates all network interfaces configured to
    # start at boot time.
    #
    ### BEGIN INIT INFO
    # Provides: $network
    # Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager $network-pre
    # Short-Description: Bring up/down networking
    # Description: Bring up/down networking
    ### END INIT INFO

    # Source function library.

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

    if [ -f /etc/sysconfig/httpd ]; then
    . /etc/sysconfig/httpd
    fi

    HTTPD_LANG=${HTTPD_LANG-"C"}

    INITLOG_ARGS=""


    apachectl=/usr/local/apache/bin/apachectl
    httpd=${HTTPD-/usr/local/apache/bin/httpd}
    prog=httpd
    pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
    lockfile=${LOCKFILE-/var/lock/subsys/httpd}
    RETVAL=0
    STOP_TIMEOUT=${STOP_TIMEOUT-10}

    start() {
    echo -n $"Starting $prog: "
    LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch ${lockfile}
    return $RETVAL
    }

    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
    }

    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

    11:让脚本可以被chkconfig管控

    # chkconfig --add /etc/rc.d/init.d/httpd-2.4

    12:使用service重启服务

    # service httpd-2.4 restart

    ##########################################

  • 相关阅读:
    Java低配版简单的随机点名系统
    是否二叉搜索树
    输出学生成绩
    求给定精度的简单交错序列部分和
    字符串的连接
    学生信息链表,建立,插入,删除,遍历,查找,修改,最大(小)值,平均
    测试文档(final)
    详细设计文档(final)
    概要设计文档(final)
    需求规格说明书(final)
  • 原文地址:https://www.cnblogs.com/ping-7/p/7912676.html
Copyright © 2011-2022 走看看