安装前说明:

  httpd安装依赖于apr-1.4+,apr-util-1.4+

  CentOS6上默认是apr-1.3, apr-util-1.3

  先下载httpd2.4、apr-1.5和apr-util-1.5

  httpd下载地址:http://httpd.apache.org/download.cgi

  apr和apr-util下载地址:https://apr.apache.org/download.cgi

开始安装:

  1. 安装开发环境,安装pcre-devel  

# yum install pcre-devel

  2. 安装apr:下载路径 https://apr.apache.org/download.cgi

# ./configure --prefix=/usr/local/apr --sysconfdir=/etc/apr
# make && make install

3. 安装apr-util:下载路径 https://apr.apache.org/download.cgi

# ./configure prefix=/usr/local/apr-util --sysconfdir=/etc/apr-util --with-apr=/usr/local/apr
# make && make install

  4. 安装httpd-2.4

# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --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

  5. 启动apache服务

  # /usr/local/bin/apachectl start
  或者添加PATH环境变量
    # vim /etc/profile.d/httpd.sh
      添加: export PATH=/usr/local/apache/bin:$PATH  //添加apache路径
    # . /etc/profile.d/httpd.sh  //重读配置文件
    # apachectl start
       Note: httpd: Could not reliably determine the server's fully qualified domain name,
          using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
         # ServerName localhost:80  //打开注释

  6. 添加服务脚本: /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/local/apache/bin/apachectl
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} # 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=2
esac exit $RETVAL
添加服务并启动httpd服务
  # cd /etc/rc.d/init.d
  # chkconfig --add httpd
  # vim /etc/profile.d/httpd.sh
     添加: export PATH=/usr/local/apache/bin:$PATH
  # ./etc/profile.d/httpd.sh
  # service httpd start

  

linux服务基础(一)之CentOS6编译安装httpd2.4的更多相关文章

  1. 在centos6编译安装http-2.4

    在centos6 编译安装httpd-2.4 安装httpd-2.4 Ü 依赖于apr-1.4+, apr-util-1.4+, [apr-iconv] Ü apr: : apache portabl ...

  2. linux服务基础(三)之Httpd2.4配置

    httpd-2.4 新特性: . MPM支持运行DSO机制,以模块形式按需加载 . 支持event MPM . 支持异步读写 . 支持每模块及每个目录分别使用各自的日志级别 . 每请求配置 <I ...

  3. linux服务基础(二)之httpd2.2基础配置

    一.安装httpd服务 CentOS6 默认安装httpd2.2版本 CentOS7 默认安装httpd2.4版本 # yum install httpd 二.安装后相关文件说明 配置文件: /etc ...

  4. CentOS6编译安装php5.3

    一.CentOS6编译安装php5.3 1.安装扩展 yum install -y openssl-devel traceroute libtool unzip gcc gcc-c++ autocon ...

  5. 在centos6编译配置httpd2.4的N种方法

    前言 我们使用linux的过程中,一定会用到httpd这个服务,在centos7上,默认安装的httpd就是2.4版本,大家都知道,2.4版本相对之前的版本已经做了改进,用起来更加方便,但是我们的ce ...

  6. 压力测试以及编译安装httpd2.4

    压力测试以及编译安装httpd2.4 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.使用 deflate_module模块压缩页面优化传输速度 我们的httpd软件自带的有一个 ...

  7. CentOS 6.8编译安装httpd2.2.31+MySQL5.6.31+PHP5.3.27

    CentOS 6.8编译安装httpd2.2.31+MySQL5.6.31+PHP5.3.27   说明:   操作系统:CentOS 6.8 32位 准备篇: 一.系统约定    软件源代码包存放位 ...

  8. CentOS7编译安装httpd-2.4.41 php7.3

    CentOS7编译安装httpd-2.4.41 php7.3 安装参考环境: CentOS Linux release 7.5.1804 (Core) 一.安装依赖包 httpd安装的依赖包 # yu ...

  9. CentOS7编译安装httpd-2.4.41

    安装参考环境: CentOS Linux release 7.5.1804 (Core) 一.安装依赖包 httpd安装的依赖包 # yum -y install pcre-devel # yum - ...

随机推荐

  1. Python初始环境搭建和Pycharm的安装

    首先我们来安装python 1.首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downloads/),进入之后如下图,选择图中红色圈中区域进行下载. 

  2. 第 1 章 JS变量、作用域

    目录 一. 判断变量类型 二.作用域 和 上下文 1. 作用链 2. 上下文(this) 二.JS的解析机制 1. 预解析 三.垃圾收集 内存管理销毁 @(es5) 基本类型 引用类型 一. 判断变量 ...

  3. 问题记录 --Error parsing column 1 (Function_Num=10 - String)”

    当C#查询数据库出现Error parsing column ## 的时候,首先去看看数据库里面该字段是什么类型,然后在看看你在创建model 的时候是什么类型,如果model的类型和数据库字段类型不 ...

  4. 理解 JavaScript 中的 this

    前言 理解this是我们要深入理解 JavaScript 中必不可少的一个步骤,同时只有理解了 this,你才能更加清晰地写出与自己预期一致的 JavaScript 代码. 本文是这系列的第三篇,往期 ...

  5. [py]python操作zookeeper

    参考: https://blog.csdn.net/heizistudio/article/details/79568188 1.安装zookeeper zookeeper-3.4.6.tar.gz ...

  6. JAVA时间Date工具类

    package com.common.util; import java.text.DateFormat; import java.text.ParseException; import java.t ...

  7. XMPP技术之Smack库的自定义消息扩展

    写此文是为了纪念我耗时两天的Smack库应用开发. 太苦恼了,网上找了一堆材料,关于XMPP的消息扩展方面的资料感觉都是出于同一个源头,基本问题还是基于的库版本都是低于4.1版本的讲解. 我是在Sma ...

  8. 集合 set

    集合 集合属于可变数据类型,但它的内容必须是不可变数据类型. 特点:无序   ,  不重复 有两种创建方式: set({1,2,3})和 {1,2,3} set1 = set({1,2,3,4}) s ...

  9. Kali-Dos洪水攻击之Hping3

    在计算机行业,拒绝服务(DoS)或分布式拒绝服务(DDoS)攻击是指不法分子企图让某机器或网络资源无法被预期的用户所使用.虽然执行DoS攻击的方式.动机和目标不一样,但通常包括设法临时性或无限期中断或 ...

  10. ngx-admin with Asp.net Core 2.0, possibly plus OrchardCore

    1 Download ngx-admin from https://github.com/akveo/ngx-admin 2 Create a new Web Application in vs201 ...