linux 编译安装 模块,Linux下编译安装Apache及模块

Apache是使用非常广泛的web服务器,多平台支持,是时下最流行的Web服务器端软件之一。Apache快速、可靠,并且可通过简单的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模块,步骤很简单。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已加载!

参考:http://blog.csdn.net/mycwq/article/details/46426261

原文:http://blog.csdn.net/mycwq/article/details/46426261

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值