阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6编译httpd-2.4.10

215次阅读
没有评论

共计 5261 个字符,预计需要花费 14 分钟才能阅读完成。

前提:

安装环境: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 portableruntimeapache可移植环境

      CentOS 6: 默认:apr-1.3.9,apr-util-1.3.9版本

      但是 httpd2.4 依赖于 较新版本的 aprapr-1.4+,apr-util-1.4+, [apr-iconv]( 可选),需编译安装

      aprapr-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

      [root@localhosttmp]# tar xf apr-1.5.0.tar.bz2

      [root@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

      [root@localhosttmp]# tar xf apr-util-1.5.3.tar.bz2

      [root@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

        [root@localhosttmp]# tar xf httpd-2.4.10.tar.bz2

        [root@localhosttmp]# cd httpd-2.4.10

        [root@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

        [root@localhosttmp]# make -j  4

        [root@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

更多 CentOS 相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-01/127611.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计5261字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中