与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。

所需源码包

apr-1.4.6.tar.gz(可从http://apr.apache.org/download.cgi下载到最新版本)
apr-util-1.4.1.tar.gz(可从http://apr.apache.org/download.cgi下载到最新版本)
httpd-2.4.6.tar.gz(可从http://www.apache.org/dist/httpd/下载到最新版本)
pcre-8.33.tar.gz(可从ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/下载到最新版本)

#安装 apr

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

#安装 apr-util

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

#安装 pcre

 cd /usr/local/src/Apache-2.4.
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--config
make && make install

注意:可能会出现"configure: error: You need a C++ compiler for C++ support.",运行以下命令安装c++编译器,再重新执行configure即可。

yum install -y gcc gcc-c++

安装 Apache2.4.6

 cd /usr/local/src/Apache-2.4.
tar -xzvf ./httpd-2.4..tar.gz
cd ./httpd-2.4.
./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 /etc/init.d/httpd #增加执行权限
chkconfig --add httpd #添加httpd到服务项
chkconfig --level 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  -j ACCEPT

#重启防火墙

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

启动Apache

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

安装过程中可能会出现以下问题:

编译Apache时出现:

 checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

解决办法:

 yum install openssl-devel

启动Apache时出现:

 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

解决办法:

#vi /etc/httpd/conf/httpd.conf (在这里/etc/httpd是我安装apache的目录)

找到#ServerName www.example.com:80   把#去掉,再重启apache即可没事了。

CentOS下编译安装Apache的更多相关文章

  1. CentOS 下编译安装Apache

    CentOS 下编译安装Apache 卸载原有的apache 首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz然后从 http://ap ...

  2. CentOS下编译安装Apache(httpd)

    官网下载最新版本的apache, apr, apr-util http://httpd.apache.org/download.cgi#apache24 http://apr.apache.org/d ...

  3. Linux(CentOS)下编译安装apache

    Centos7.6系统 已经安装lnmp一键环境 想装个apache跑php7 (php7的安装以及与apache的交互在这里: https://www.cnblogs.com/lz0925/p/11 ...

  4. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

  5. Linux下编译安装Apache Http Server

    Linux下编译安装Apache Http Server [TOC] 1.下载httpd-2.4.12.tar.bz2 wget http://mirror.bit.edu.cn/apache/htt ...

  6. 转:在CentOS下编译安装GCC

    转:https://teddysun.com/432.html 在CentOS下编译安装GCC 技术  秋水逸冰  发布于: 2015-09-02  更新于: 2015-09-02  6519 次围观 ...

  7. centos手动编译安装apache、php、mysql

    64位centos 5.5手动安装lamp,要求curl.json.pdo_mysql.gd,记录如下. centos 5.4.5.5.5.6的内核都是2.6.18,都可以安装php 5.3. 卸载旧 ...

  8. centos下编译安装mysql5.6

    CentOS 6.4下编译安装MySQL 5.6.14 参考:http://www.cnblogs.com/xiongpq/p/3384681.html 概述: CentOS 6.4下通过yum安装的 ...

  9. CentOS下编译安装MySQL 5.6.21

    一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake:http://www.cnblog ...

随机推荐

  1. MD5工具类-详细

    public class MD5Code { /* * 下面这些S11-S44实际上是一个4*4的矩阵,在原始的C实现中是用#define 实现的, 这里把它们实现成为static * final是表 ...

  2. The IDL compiler

    The IDL compiler or bindings generator transcompiles Web IDL to C++ code, specifically bindings betw ...

  3. Web开发、原生开发、混合开发的区别优势:

    一.Web 应用 Web应用本质上是为移动浏览器设计的基于Web的应用,它们是用普通Web开发语言开发的,可以在各种智能手机浏览器上运行. 优点: 支持设备广泛: 较低的开发成本: 可即时上线: 无内 ...

  4. 洛谷 P2542 [AHOI2005]航线规划 树链剖分_线段树_时光倒流_离线

    Code: #include <map> #include <cstdio> #include <algorithm> #include <cstring&g ...

  5. S-Nim POJ - 2960 Nim + SG函数

    Code: #include<cstdio> #include<algorithm> #include<string> #include<cstring> ...

  6. CF85E Guard Towers(二分答案+二分图)

    题意 已知 N 座塔的坐标,N≤5000 把它们分成两组,使得同组内的两座塔的曼哈顿距离最大值最小 在此前提下求出有多少种分组方案 mod 109+7 题解 二分答案 mid 曼哈顿距离 >mi ...

  7. WPS for Linux使用测评

    从去年有WPS for Linux的消息到现在,Linux 版的WPS Office在经过一系列的alpha版本之后终于迎来了Beta版本.笔者也是第一时间下载安装,WPS 文字.WPS 演示和WPS ...

  8. Linux学习,部署django项目到服务器,及安装python,uwsgi等

    开启网络 vi /etc/sysconfig/network-script/ifcfg-eth0 onboot=yes 退出保存 service network restart ping www.ba ...

  9. 《2017全球人工智能人才白皮书》发布丨解读世界顶级AI牛人的秘密——腾讯研究院

    <2017全球人工智能人才白皮书>发布丨解读世界顶级AI牛人的秘密——腾讯研究院:下载链接:http://www.tisi.org/c16 这个报告写的很好,排版布局,表格,色调,内容都值 ...

  10. 坑爹的RockSaw和坑爹的windows7

    坑爹的RockSaw和坑爹的windows7 http://chen4w.iteye.com/blog/1153433