httpd-2.4 编译安装

安装环境

  1. 系统环境:CentOS 6.5-x86_64

  2. 所需软件包:

    1. apr-1.5.0.tar.bz2

    2. apr-util-1.5.3.tar.bz2

    3. httpd-2.4.9.tar.bz2

  3. 下载地址:

    1. http://apr.apache.org/

    2. http://httpd.apache.org/

安装步骤

  1. 注:httpd-2.4版本依赖于更高版本(1.5版本以上)的apr和apr-util;apr全称为apache portable
    runtime,能实现httpd跨平台运行

  2. 解决依赖关系

    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

  3. 编译安装apr-1.5.0

    tar xf apr-1.5.0.tar.bz2
    cd apr-1.5.0
    ./configure --prefix=/usr/local/apr
    make && make install

  4. 编译安装apr-util-1.5.3

    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

  5. httpd编译安装


tar xf httpd-2.4.9.tar.bz2
cd httpd-2.4.9
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd249 --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-deflate --with-z --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
# 各编译参数详解
--prefix:#安装路径
--sysconfdir:#指定配置文件路径
--enable-so:#DSO兼容,DSO=Dynamic Shared Object,动态共享对象,可实现模块动态生效
--enable-ssl:#支持SSL/TLS,可以实现https访问
--enable-cgi:#支持CGI脚本(默认对非线程的MPM模式开启)
--enable-rewrite:#启用Rewrite功能
--enable-deflate:#支持压缩
--with-z:#使用指定的zlib库,不指定路径会自动寻找
--with-pcre:#使用指定的PCRE库,不指定路径会自动寻找
--with-apr:#指定apr安装路径
--with-apr-util:#指定apr-util安装路径
--enable-modules:#支持动态启用的模块,可选参数有“all”,“most”,“few”,“reallyall”
--enable-mpms-shared:#支持动态加载的MPM模块,可选“all”
--with-mpm:#设置默认启用的MPM模式

后续配置

i.修改httpd的主配置文件,设置其Pid文件的路径

ln -sv /usr/local/apache/include /usr/include/httpd

ii.导出头文件

ln -sv /usr/local/apache/include /usr/include/httpd

iii.导出man手册

vi /etc/man.config
MANPATH /usr/local/apache/man # man文件在apache安装目录下哦

iv.编写服务脚本(因是编译安装,不会自动生成服务脚本)


# vi /etc/rc.d/init.d/httpd
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve # HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# 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=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start;;
stop)
stop;;
status)
status -p ${pidfile} $httpd
RETVAL=$?;;
restart)
stop
start;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi;;
reload)
reload;;
graceful|help|configtest|fullstatus)
$apachectl [email protected]
RETVAL=$?;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL

启动服务并测试

# 为服务脚本赋予执行权限:
chmod +x /etc/rc.d/init.d/httpd
# 加入服务列表:
chkconfig --add httpd
# 启动服务
service httpd start

浏览器访问:http://Server_IP/   # 显示“It works”,即表示httpd服务启动成功

httpd 2.4新特性说明

  1. 新增特性

    1. MPM支持在运行时装载

    2. 支持event MPM类型

    3. 支持异步读写

    4. 在每模块及每目录上指定日志级别

    5. 每请求配置:<If>,<Elseif>

    6. 增强版的表达式分析器

    7. 毫秒级的keepalive timeout

    8. 基于FQDN的虚拟主机不再需要NameVirtualHost指令

    9. 支持使用自定义变量

  2. 新增模块

    1. mod_proxy_fcgi

    2. mod_ratelimit

    3. mod_request

    4. mod_remoteip

  3. 修改

    1. 对于基于IP的访问控制做了修改,不再支持使用order, allow,
      deny这些机制,而是统一使用require进行

时间: 2024-08-06 14:20:29

httpd-2.4 编译安装的相关文章

httpd源码编译安装

什么是编译安装——编译:将源代码变为机器可执行的代码文件.安装:将可执行文件安装到操作系统里,才可以使用. 一.下载httpd源码包 在官网上下载httpd源码包http://httpd.apache.org,也可以在linux中输入rpm -qi httpd查看到当前下载源码httpd的网址 下载到linux的data目录下,然后进行解压: [[email protected]]#rz [[email protected]]#tar xf httpd-2.4.39 注意:一定要在解压后的htt

Linux httpd源码编译安装

# wget http://apache.fayea.com/httpd/httpd-2.2.31.tar.bz2 去官网下载源码包 # mv httpd-2.2.31.tar.bz2 /usr/local/src/ 为方便管理源码包 统一放在一个文件下 # tar -jxvf httpd-2.2.31.tar.bz2 # cd httpd-2.2.31 # ls ABOUT_APACHE config.log httpd.mak Makefile README acinclude.m4 con

编译安装httpd 2.4 ---格式待整理

httpd 2.4 版本需要依赖于apr 1.4版本httpd 依赖于 apr,apr-util    其安装又先后顺序之分:        1.apr        2.apr-util        3.httpd [[email protected] httpd]# rpm -q httpdhttpd-2.2.15-39.el6.centos.x86_64[[email protected] httpd]# service httpd stopStopping httpd:        

编译安装httpd服务

首先,编译安装http,需要有它的源码包,这里提供官方下载:http://httpd.apache.org 我使用的是httpd-2.4.4.tar.bz2软件包 在进行源码编译安装之前,我们需要设定一下安装环境 1.安装开发包组: # yum groupinstall "Development tools" "Server Platform Development" "Desktop Platform Development" "Co

编译安装lamp

软件包链接: http://pan.baidu.com/s/1mijn44g     密码:abja 系统环境:centos 7 开发环境:Development tools.Server Platform Development http+php的方式:PHP模块化 个程序版本: mariadb mariadb-5.5.46-linux-x86_64.tar.gz http httpd-2.4.10.tar.bz2 PHP php-5.4.40.tar.bz2 一.编译安装mariadb ①创

CentOS 6上编译安装AMP详解

在CentOS 6上编译安装AMP     A:Apache(httpd)     M:MySQL or MariaDB     P:php 目录: 一.准备工作 二.编译安装Apache(httpd) 三.编译安装MariaDB 四.编译安装PHP 编译安装AMP的优点: 根据生产环境灵活定制程序 优化编译参数,提高性能 解决不必要的软件依赖 一.准备工作 1.需要的软件包及版本号: httpd-2.4.27(apr-1.5.2+ apr-util-1.5.4) + MariaDB-5.5.5

编译安装LAMP(两种场景)

编译安装LAMP 场景一:AP组合以模块方式结合(编译PHP作为httpd的模块):进而完成虚拟主机PMA(phpmyadmin)和discuz论坛 场景二:AP组合以fpm方式,PHP独立守护进程运行:进而完成虚拟主机PMA(phpmyadmin)和discuz论坛 ==========================场景一============================ 拓扑结构: 主机一 网卡1IP为172.20.1.100 网卡2IP为192.168.217.219 在此计算机上

运维工作必备----------编译安装LAMP

1.编译安装介绍 在工作中,基于各种生产环境下,可能yum安装不能满足我们的需求.这个时候我们就得自己动手编译安装软件包,当然只要掌握了技巧,其实编译安装也非常的简单.本文将介绍如何在CentOS 6.7系统下编译安装:httpd-2.4.6 + php-5.6.4 + xcache-3.2.0 + mariadb-5.5.43,编译完成后基于LAMP环境搭建一个Wordpress 和phpMyAdmin. 2.编译安装 2.1 mariadb-5.5.43 准备数据存放的文件系统 新建一个逻辑

在win7系统上,使用3台CentOS 6, (编译安装http2.4、php、mysql)

实验要求:搭建lamp (1) 三者分离于三台主机: (2) 一个虚拟主机用于提供phpMyAdmin:另一个虚拟主机用于提供wordpress: (3) xcache (4) mpm为worker机制: 物理机使用win7系统,在VMware虚拟机中准备了3台centos6.7的linux系统: 其中IP地址设计: web服务器地址为:192.168.255.60 php服务器地址为:192.168.255.61 mysql数据库服务器地址为:192.168.255.62 分别在每台服务器上编

Centos6.7 编译安装 Apache PHP

Centos6.7 编译安装 Apache PHP ##### Apache 编译安装 #### [[email protected] ~]# yum install gcc gcc-c++ make wget [[email protected] ~]# yum install zlib-devel openssl-devel [[email protected] ~]# yum install -y perl perl-devel 1) apr [[email protected] src]