編譯安裝httpd-2.4.9

來源:互聯網
上載者:User

標籤:linux

(一)介紹:

  Apache是世界使用排名第一的Web伺服器軟體。它可以運行在幾乎所有廣泛使用的電腦平台上,由於其跨平台和安全性被廣泛使用,是最流行的Web伺服器端軟體之一。它快速、可靠並且可通過簡單的API擴充,將Perl/Python等解譯器編譯到伺服器中。同時Apache音譯為阿帕奇,是北美印第安人的一個部落,叫阿帕奇族,在美國的西南部。也是一個基金會的名稱、一種武裝直升機等等。   

(二)安裝方式|版本

    安裝方式(1.編譯安裝 2.rpm包安裝)

    版本(httpd-2.0  httpd-2.2  httpd-2.4最新版本) 

(三)httpd2.4新特性:

1) MPM支援運行時裝載

--enable-mpms-shared=all --with-mpm=prefork|worker|event

2) 支援event MPM

3) 非同步讀寫支援

4) 支援每模組及每目錄分別使用不同的記錄層級

5) 支援per-request(即支援<If>, <ElseIf>, and <Else>條件判斷)

6) 增強版的運算式分析器;

7) 支援毫秒級keepalive timeout;

8) 基於FQDN(網域名稱)的虛擬機器主機不再需要NameVirtualHost; 

9) 支援使用者使用自訂變數; 

新增模組:mod_proxy_fcgi, mod_ratelimit, mod_request, mod_remoteip

備忘:2.4版本修改了一些配置機制:不再支援使用order, allow, deny來實現基於IP的存取控制;

(四)編譯安裝:

  編譯前:編譯依賴開發環境,yum groupinstall Development tools Server Platform Development -y

    編譯三部曲:檢查編譯環境,編譯,安裝

    編譯安裝apr和apr-util

       tar xf apr-1.5.0.tar.bz2 

       cd apr-1.5.0

       ./configure --prefix=/usr/local/apr

       make && make install

       tar xf apr-util-1.5.3.tar.bz2 

       cd apr-util-1.5.3

       ./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr/

       make && make install

    編譯安裝httpd2.4

      cd httpd-2.4.9

      ./configure --prefix=/usr/local/apache  --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=event  && make && make install         #編譯模組

 

    vim /etc/rc.d/init.d/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/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: 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/sbin/apachectl

httpd=${HTTPD-/usr/sbin/httpd}

prog=httpd

pidfile=${PIDFILE-/var/run/httpd/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.

        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() {

        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

}


# 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 [email protected]

        RETVAL=$?

        ;;

  *)

        echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"

        RETVAL=2

esac


exit $RETVAL


(五)啟動測試

  service httpd start

(六)httpd工具

   httpd命令是Apache HTTP伺服器程式。

     參數說明:

  • -c<httpd指令> 在讀取設定檔前,先執行選項中的指令。

  • -C<httpd指令> 在讀取設定檔後,再執行選項中的指令。

  • -d<伺服器根目錄> 指定伺服器的根目錄。

  • -D<設定檔案參數> 指定要傳入設定檔的參數。

  • -f<設定檔案> 指定設定檔。

  • -h 顯示協助。

  • -l 顯示伺服器編譯時間所包含的模組。

  • -L 顯示httpd指令的說明。

  • -S 顯示設定檔中的設定。

  • -t 測試組態檔案的文法是否正確。

  • -v 顯示版本資訊。          

  • -V 顯示版本資訊以及建立環境。             

  • -X 以單一程式的方式來啟動伺服器。


編譯安裝httpd-2.4.9

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.