分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

centos6编译httpd2.4

发布时间:2023-09-06 01:19责任编辑:彭小芳关键词:http编译

1.

tar xvf apr-1.6.2.tar.gz 

tar xvf apr-util-1.6.0.tar.gz 

tar xvf httpd-2.4.28.tar.bz2 

2.

cp -a apr-1.6.2 httpd-2.4.28/srclib/apr

cp -a apr-util-1.6.0 httpd-2.4.28/srclib/apr-util

3.

getent passwd apache查看apache帐户

须保证apache用户为系统用户

则需要userdel -r apache删除用户重新创建

创建apache用户需指定家目录及登录shell

groupadd -g 48 -r apache;useradd -r -u 48 -g apache -s /sbin/nologin -d /usr/share/httpd -c "Apache" apache 规范点的写法如此,也可以简单的写

useradd -r -d /app/httpd24 -m -s /sbin/nologin apache

4.

缺包装包

yum groupnstall ‘development-tools‘

yum install openssl-devel pcre-devel expat-devel

5.

cd httpd-2.4.28/

./configure --prefix=/app/httpd24 \

--enable-so \

--enable-ssl \

--enable-cgi \

--enable-rewrite \

--with-zlib \

--with-pcre \

--with-included-apr \

--enable-modules=most \

--enable-mpms-shared=all \

--with-mpm=prefork

6.make -j 4 && make install

7.

path变量

vim /etc/profile.d/httpd.sh

PATH=/app/httpd24/bin:$PATH


. /etc/profile.d/httpd.sh

8.

修改运行服务的用户

vim /app/http24/conf/httpd.conf

User apache

Group apache


9.准备服务脚本

cd /etc/init.d

cp httpd httpd24


服务脚本httpd,这里改为httpd24以便区分。httpd为原httpd包自带的,rpm -q --scripts 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/functionsif [ -f /etc/sysconfig/httpd ]; then        . /etc/sysconfig/httpdfi# 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/apachectlhttpd=${HTTPD-/usr/sbin/httpd}prog=httpdpidfile=${PIDFILE-/var/run/httpd/httpd.pid}lockfile=${LOCKFILE-/var/lock/subsys/httpd}RETVAL=0STOP_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.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 $@        RETVAL=$?        ;;  *)        echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"        RETVAL=2esacexit $RETVAL


更改相关路径

vim httpd24

apachectl=/app/httpd24/bin/apachectl

httpd={HTTPD-/app/httpd24/bin/httpd}

pidfile={PIDFILE-/app/httpd24/logs/http.pid}

lockfile={LOCKFILE-/var/lock/subsys/httpd24}


启动服务

chkconfig --add httpd24

chkconfig httpd24 on

service httpd24 start


10.测试



本文出自 “RightNow” 博客,请务必保留此出处http://amelie.blog.51cto.com/12850951/1974891

centos6编译httpd2.4

原文地址:http://amelie.blog.51cto.com/12850951/1974891

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved