Apache是时下最流行的Webserver软件之中的一个,支持多平台,可高速搭建web服务,并且稳定可靠。并可通过简单的API扩充。就能够集成PHP/Python等语言解释器。

文章这里解说怎样在linux下编译 Apache,以及怎样编译Apache模块。

linux下编译Apache

下载Apache源码,编译步骤例如以下:
$ wget http://apache.fayea.com//httpd/httpd-2.4.12.tar.gz
$ tar -zxf httpd-2.4.12.tar.gz
$ cd httpd-2.4.12
$ ./configure --prefix=/usr/local/apache/
$ make && make install
编译过程中。可能会出现了下面错误:
$ ./configure --prefix=/usr/local/apache/
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.

这里是由于Apache编译依赖 apr。没找到 apr 就无法正常安装。另外,Apache还依赖 apr-util 和 pcre

编译Apache依赖

APR是Apache可移植执行库。封装了全部操作系统调用。用来实现Apache内部组件对操作系统资源的使用。提高Apache的可移植性。APR和Apache分离出来,避免Apache开发过程中。还要针对不同的平台做不同处理。apr-util 相当于APR工具集。PCRE是实现正则的perl库。
编译和安装 APR
$ wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
$ tar -zxf apr-1.5.2.tar.gz
$ cd apr-1.5.2
$ ./configure --prefix=/usr/local/apr 
$ make && make install
编译和安装 apr-util
$ wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
$ tar -zxf apr-util-1.5.3.tar.gz
$ cd apr-util-1.5.3
$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ make && make install
编译和安装 pcre
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
$ tar -zxf pcre-8.37.tar.gz 
$ cd pcre-8.37
$ ./configure --prefix=/usr/local/pcre
$ make && make install
又一次编译Apache
安装Apache依赖后,编译时加多几个參数,又一次编译Apache
$ ./configure --prefix=/usr/local/apache/ \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre
$ make && make install

编译Apache模块

这里以mod_concatx为例,说明怎样编译Apache模块,步骤非常easy。mod_concatx是apache模块,能够用来合并多个js/css。有效提高js/css载入速度
编译 mod_concatx 模块
$ wget http://apmod.googlecode.com/svn/trunk/mod_concatx/mod_concatx.c
$ ln -s /usr/local/apache/bin/apxs /usr/local/bin/apxs
$ apxs -c mod_concatx.c
编译并安装mod_concatx 模块
$ apxs -iac mod_concatx.c
这样的编译方式会自己主动安装Apache模块,成功安装后,能够在Apache 模块文件夹找到 mod_concatx.so。并且 conf/httpd.conf 配置也会加上 mod_concatx 模块信息
启动Apache
$ /usr/local/apache/bin/httpd -k start
注:Apache启动后,以后台服务执行。

假设想关闭Apache, 就使用下面命令:

$ /usr/local/apache/bin/httpd -k stop
查看已载入的Apache模块
$ /usr/local/apache/bin/httpd -M
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 concatx_module (shared)
说明mod_concatx已载入!

Apache无法正常执行的解决的方法

1. 80port被占用

$ netstat -anp | grep :80
找到占用port的Pid,kill掉就可以。

2. 防火墙默认禁用80port

$ vi /etc/sysconfig/iptables
加多一行记录
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
保存后,重新启动防火墙。
$ service iptables restart
2015/6/11  补充Linux下Apache无法正常执行的解决的方法
參考:http://blog.csdn.net/mycwq/article/details/46426261

Linux下编译安装Apache及模块的更多相关文章

  1. Linux下编译安装Apache Http Server

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

  2. Linux下编译安装Apache 2.4

    Linux一般会自带httpd服务,但是版本一般不是最新,性能也不是最好,生产中建议手动安装官方源码包,安装Apache官方包之前首先要停止之前的httpd服务,停止后也可以卸载之前的版本 准备工作做 ...

  3. linux下编译安装apache

    在linux(CentOS6.5)上安装Apache,要首先确保以下程序事先安装 apr:The mission of the Apache Portable Runtime (APR) projec ...

  4. Linux下编译安装Apache报APR not found错误的解决办法

    我在编译安装完Nginx.MySQL和PHP(见之前一篇博客:LNMP环境搭建详细教程)之后,进行apache的编译安装: cd /usr/local/src wget http:.tar.gz ta ...

  5. linux中编译安装Apache、PHP、MySQL(上)

    1.简介 在阿里云买了个云服务器,一直没时间折腾.过了近十天了吧,才有时间好好玩玩这个云服务器.自己是做Web开发的,所以我需要的开发环境是LAMP.之前打算是采用yum安装,不过yum安装apach ...

  6. 在linux下手动安装 apache, php, mysql--终极版

    在linux下手动安装 apache, php, mysql: 参考: http://www.cnblogs.com/lufangtao/archive/2012/12/30/2839679.html ...

  7. Linux下编译安装qemu和libvirt

    目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 2 安装libvirt 2.1 libvirt介绍 2.2 下载libvirt 2.3 编译安装 3  ...

  8. Linux下编译安装qemu和libvirt【转】

    转自:http://www.cnblogs.com/findumars/p/5679742.html 目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 ...

  9. CentOS 下编译安装Apache

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

随机推荐

  1. 6、第六课,js jquery20150928

    1.声明事件,给事件添加动作 function MyClick() { alert("这是我的第一个js") } 2.js特点 A.js区分大小写 B.弱类型变量,定义一个变量 v ...

  2. HTML5新增的属性和废除的属性

    HTML5中,在新增加和废除很多元素的同时,也增加和废除了很多属性. 新增的属性 1.表单相关的属性 对input(type=text).select.textarea与button指定autofoc ...

  3. Android学习手记(6) TabActivity和TabHost

    使用TabHost可以实现标签式效果,将两个Activity放在两个Tab内. 首先,需要基于MainActivity创建一个TabHost对象. TabHost tabHost = this.get ...

  4. iOS 8 自动布局sizeclass和autolayout的基本使用

    1.首先创建新的工程,设置rootviewcontroller(这里不再多说) 2.勾选下面(因为我们到下面是使用sizeClass,所以勾选两个): 3.这里我创建了一个lable,名称为View1 ...

  5. 信息增益(IG,Information Gain)的理解和计算

    决策树构建中节点的选择靠的就是信息增益了. 信息增益是一种有效的特征选择方法,理解起来很简单:增益嘛,肯定是有无这个特征对分类问题的影响的大小,这个特征存在的话,会对分类系统带来多少信息量,缺了他行不 ...

  6. STL-空间配置器(allocator)

    STL的空间配置器作为STL六大部件的重要组成部分,它总是隐藏在一切组件的背后.它主要负责动态空间的分配.释放等管理工作.整个STL的操作对象(所有的数值)都存放在容器之内,而容器一定需要配置空间以置 ...

  7. MetInfo操作笔记

    1.去版权(前台) 文件路径:templates/模板名称/foot.php <div class="powered_by_metinfo">Powered by &l ...

  8. PHPCMS V9二次开发便捷自定义后台入口文件夹

    phpcms v9二次开发便捷自定义后台入口文件夹 最新发布的phpcms v9由于采用了mvc的设计模式,所以它的后台访问地址是固定的,虽然可以通过修改路由配置文件来实现修改,但每次都修改路由配置文 ...

  9. jQuery制作go to top按钮

    转自:http://www.w3cplus.com/jquery/scrolling-to-the-top-with-jquery 每每看到网友Blog的页面底部或中间有一个按钮回到页面顶部,羡慕死人 ...

  10. 安全cookie登录状态设计方案

    我们知道web是基于HTTP协议传输的,明文传输是极其危险的,随便哪个抓包工具分析下数据包,就over啦,一个加密的传输过程应该包括两部分,一部分为身份认证,用户鉴别这个用户的真伪:另外一部分为数据加 ...