Apache 编译安装

BerkeleyDB

./dist/configure --prefix=/usr/local/BerkeleyDB --enable-dbm --enable-share
make
make install

安装完成后,需要将 BerkeleyDB 的动态库,写入 /etc/ld.so.conf,否则有的程序找不到 BerkeleyDB 相应的动态库

echo "/usr/local/BerkeleyDB/lib" > /etc/ld.so.conf
ldconfig

Apr

    安装 apache http server 和 apr-util,需要依赖于 apr。

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

Apr-util

安装 apache http server,需要依赖于 apr-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-berkeley-db=/usr/local/BerkeleyDB
make
make install

Cronolog

apache 日志自动切割工具,可以减小 apache 日志文件大小,提高读写效率

./configure --prefix=/usr/local/cronolog
make
make install

Apache HTTP Server 安装

./configure --prefix=/usr/local/apache --with-port=8080 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-shared=max --enable-deflate --disable-authn-user --enable-cache
 --enable-file-cache  --enable-cache-disk --enable-mime-magic --enable-expires --enable-remoteip --enable-static-support --enable-static-htpasswd --enable-info
make
make install

Apache HTTP Server 参数设置

ff

Apache HTTP Server service 脚本

将以下内容,写入脚本:/etc/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: /usr/local/apache/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/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.
APACHE_HOME=/usr/local/apache
apachectl=${APACHE_HOME}"/bin/apachectl"
httpd=${HTTPD-${APACHE_HOME}"/bin/httpd"}
PROG=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}

STOP_TIMEOUT=${STOP_TIMEOUT-10}
RETVAL=0

# 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
}

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
}

# 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() {
    echo -n $"Stopping $PROG: "
    killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

case "$1" in
  start)
    start
    ;;
  force-reload|reload)
    reload
    ;;
  restart)
    stop
    start
    ;;
  stop)
    stop
    ;;
  status)
    status -p ${pidfile} $httpd
    RETVAL=$?
    ;;
  condrestart|try-restart)
    if status -p ${pidfile} $httpd > &/dev/null; then
        stop
        start
    fi
    ;;
  graceful|help|configtest|fullstatus)
    $apachectl $@
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $PROG {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|configtest|help}"
    RETVAL=2
esac

exit $RETVAL

chmod +x /etc/init.d/httpd

Apache HTTP Server 开机自启动

chkconfig --add httpd
chkconfig --level 235 httpd on


你可能感兴趣的:(Apache 编译安装)