Apache官方说:

与Apache 2.2.x相比,Apache 2.4.x提供了很多性能方面的提升,包括支持更大流量、更好地支持云计算、利用更少的内存处理更多的并发等。除此之外,还包括性能提升、内存利用、异步I/O的支持、动态反向代理设置、与时间驱动的Web服务器相当或更好的性能、更强大的处理资源分配能力,更便捷的缓存支持以及可定制的高速服务器和代理等。其它的功能还包括更简单的错误分析、更灵活的设置项、更强大的验证机制和更完整的文档。

Apache服务器项目管理委员会和Apache基金会主席Jim Jagielski表示,他们希望终端用户能真正地看到性能进步,Apache 2.4.x比许多以速度见长的Web服务器更快,例如 Nginx。

apache-2.2与新出的apache-2.4安装不同的地方在于,2.4版的已经不自带apr库,所以在安装apache-2.4之前,需要下载apr。

所需源码包

/usr/local/src/Apache-2.4.6/apr-1.4.6.tar.gz
/usr/local/src/Apache-2.4.6/apr-util-1.4.1.tar.gz
/usr/local/src/Apache-2.4.6/httpd-2.4.6.tar.gz

安装Apache依赖库

#安装 apr

cd /usr/local/src/Apache-2.4.6
tar -xzvf ./apr-1.4.6.tar.gz
cd ./apr-1.4.6
mkdir /usr/local/apr
./configure --prefix=/usr/local/apr
make && make install

#安装 apr-util

cd /usr/local/src/Apache-2.4.6
tar -xzvf ./apr-util-1.4.1.tar.gz
cd ./apr-util-1.4.1
mkdir /usr/local/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install

#安装 pcre

cd /usr/local/src/Apache-2.4.6
tar -xzvf ./pcre-8.33.tar.gz
cd ./pcre-8.33
mkdir /usr/local/pcre
./configure --prefix=/usr/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config
make && make install

安装 Apache2.4.6

#切换到apache源码目录

cd /usr/local/src/Apache-2.4.6
tar -xzvf ./httpd-2.4.6.tar.gz
cd ./httpd-2.4.6

#生成configure

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-deflate=shared --enable-expires=shared --enable-ssl=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support --with-mpm=prefork

#编译

make && make install

编译参数解释:

--prefix=/usr/local/apache :指定安装目录
--with-apr=/usr/local/apr : apr库
--with-apr-util=/usr/local/apr-util :apr-util库
--with-pcre=/usr/local/pcre : pcre库
--enable-so : 允许运行时加载DSO模块(注意:so模块需静态编译)
--enable-deflate=shared : 将deflate模块编译为DSO
--enable-expires=shared : 将expires模块编译为DSO
--enable-ssl=shared : 将ssl模块编译为DSO
--enable-headers=shared : 将headers模块编译为DSO
--enable-rewrite=shared : 将rewrite模块编译为DSO
--enable-static-support : 使用静态连接(默认为动态连接)编译所有二进制支持程序
--with-mpm=prefork : 使用prefork形式的mpm

更详细的编译参数解释:http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/configure.html

cp ./build/rpm/httpd.init  /etc/init.d/httpd  #使用init脚本管理httpd
chmod 755 /etc/init.d/httpd #增加执行权限
chkconfig --add httpd #添加httpd到服务项
chkconfig --level 2345 httpd on #设置开机启动
chkconfig --list httpd #查看是否设置成功 mv /etc/httpd /etc/httpd_old #移走旧的httpd文件夹
ln -s /usr/local/apache /etc/httpd #建立httpd的软链接,
#到时候,Apache的配置文件路径为 /etc/httpd/conf/httpd.conf,其实真实路径为 /usr/local/apache/conf/httpd.conf ln -sf /usr/local/apache/bin/httpd /usr/sbin/httpd #设置软链接以适应init脚本
ln -sf /usr/local/apache/bin/apachectl /usr/sbin/apachectl rm -rf /var/log/httpd/
ln -s /usr/local/apache/logs /var/log/httpd groupadd apache #添加apache用户组及用户
useradd -g apache -s /usr/sbin/nologin apache
chown -R apache:apache /usr/local/apache

修改init命令文件

主要是修改文件中pidfile参数的值(进程文件指向)

vim /etc/init.d/httpd

把其中的

pidfile=${PIDFILE-/var/run/${prog}.pid}

修改为

pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}

配置防火墙,开启80端口

vim /etc/sysconfig/iptables

#添加如下规则到22端口这条规则的下面即可

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

#重启防火墙

service iptables restart # 或 /etc/init.d/iptables restart

启动Apache

service httpd start # 或 /etc/init.d/httpd start

延伸阅读:

CentOS6.x编译安装LAMP(1):准备工作

CentOS6.x编译安装LAMP(2):编译安装 Apache2.2.25

CentOS6.x编译安装LAMP(2):编译安装 Apache2.4.6

CentOS6.x编译安装LAMP(3):编译安装 MySQL5.5.25

CentOS6.x编译安装LAMP(4):编译安装 PHP5.2.17

CentOS6.x编译安装LAMP(4):编译安装 PHP5.3.27

PHP5不重新编译,如何安装自带的未安装过的扩展,如soap扩展?

Apache常用2种工作模式prefork和worker比较

CentOS编译安装Apache 2.4.x时报错:configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

CentOS6.3 编译安装LAMP(2):编译安装 Apache2.4.6的更多相关文章

  1. CentOS 6编译安装lamp,并分别安装event模块方式和FPM方式的PHP

    任务目标: 编译安装LAMP 要求(1) 安装一个模块化的PHP 要求(2) 安装一个FPM的PHP 注意PHP需要最后一个安装,因为需要前两者的支持. 所以这里的安装次序为 1.httpd 2.Ma ...

  2. CentOS 6.3下源码编译安装LAMP

    一.简介 什么是LAMP    LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...

  3. Centos6.5添加Epel和Remi源安装Lamp环境

    想搭建一个Lamp环境,因为编译安装太麻烦,对于我这样的新手来说,太过于复杂.而CentOS自带的Apache.MySql和PHP的版本都太低,不想用.上百度搜了一轮,原来可以通过添加Epel和Rem ...

  4. CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境

    一.简介 什么是LAMP    LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...

  5. CentOS 6.3 源码安装LAMP(Linux+Apache+Mysql+Php)环境

    一.简介 什么是LAMP LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而>言都是在它所 ...

  6. CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境【转载】

    本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/11/28/2778779.h ...

  7. CentOS 下源码安装LAMP环境

    一.简介 什么是LAMP    LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...

  8. CentOS 6.5下源码安装LAMP(Linux+Apache+Mysql+Php)环境

    ---恢复内容开始--- 一.系统环境 系统平台:CentOS 6.5 (Final) Apache版本:httpd-2.2.31.tar.gz(最新版本2015-07-16) Mysql 版本:my ...

  9. CentOS 6.6安装LAMP和Subversion服务器

    目标:在CentOS 6.6上安装LAMP,并安装最新版1.8.*的Subversion服务器,和Subversion权限管理前端iF.svnadmin. 安装步骤: 安装新一些版本LAMP步骤 1. ...

  10. ubuntu12.04&15.04 安装lamp(12.04为主)

    ubuntu 12.04&15.04下安装lamp环境 注意:如果是ubuntu15.04下,apache2.4.10的话,直接在/etc/apache2/apache2.conf文件的后边直 ...

随机推荐

  1. SSH----小小项目的小小总结

    嘛,之前学了一下SSH框架,跟人合作写了个小东西参加比赛,(当然我是队长),真的感慨良多~,现在用这篇博客记录下来吧 1.责任心/责任感 首先要说的一点,要有责任心,当你与别人组成一个团队的时候,虽然 ...

  2. POJ2425 A Chess Game[博弈论 SG函数]

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3917   Accepted: 1596 Desc ...

  3. POJ2167Irrelevant Elements[唯一分解定理 组合数 杨辉三角]

    Irrelevant Elements Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2407   Accepted: 59 ...

  4. [bzoj1901][zoj2112][Dynamic Rankings] (整体二分+树状数组 or 动态开点线段树 or 主席树)

    Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has ...

  5. 国内外前端(js)开发框架对比

    国内外前端开发框架对比 首先我们先对目前国内外主流前端开发框架做一个基本的了解,之后再对他们进行一个直观的对比. Bootstrap Bootstrap(http://www.bootcss.com) ...

  6. Linux基础 - scp免密码登陆进行远程文件同步

    在工作中经常有遇到需要脚本自动化同步文件的地方,比如数据库异地备份.假设有两台机子A(192.168.16.218)和B(192.168.16.117),需要能够让A免密码连接B. 先来看看正常的ss ...

  7. edge 浏览器中数字显示为链接

    在win10 中的Edge浏览器中部分格式的数字显示链接.经过各种搜索找到一篇文章 How to remove phone number link on Iphone? ,通过这篇文章了解 edge ...

  8. Android 高清加载巨图方案 拒绝压缩图片

    Android 高清加载巨图方案 拒绝压缩图片 转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/49300989: 本文出自:[张 ...

  9. jquery 使用方法

      jQuery是目前使用最广泛的javascript函数库.据统计,全世界排名前100万的网站,有46%使用jQuery,远远超过其他库.微软公司甚至把jQuery作为他们的官方库.对于网页开发者来 ...

  10. 理解javascript this指向

    匿名函数中的this指向window对象 这句话很经典: 每个函数在调用时,其活动对象都会自动获取两个特殊的变量:this和arguments.内部函数在搜索这两个变量时,只会搜到其活动对象为止,因此 ...