分享web开发知识

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

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

编译安装httpd-2.4

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

首先要准备好环境,然后下载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

编译安装httpd-2.4

原文地址:http://www.cnblogs.com/ping-7/p/7912676.html

知识推荐

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