Linux下编译安装Apache及模块
2015-06-09 19:24
483 查看
Apache是时下最流行的Web服务器软件之一,支持多平台,可快速搭建web服务,而且稳定可靠,并可通过简单的API扩充,就可以集成PHP/Python等语言解释器。文章这里讲解如何在linux下编译 Apache,以及如何编译Apache模块。
编译过程中,可能会出现了以下错误:
这里是因为Apache编译依赖 apr,没找到 apr 就无法正常安装。另外,Apache还依赖 apr-util 和 pcre
编译和安装 APR
编译和安装 apr-util
编译和安装 pcre
重新编译Apache安装Apache依赖后,编译时加多几个参数,重新编译Apache
编译并安装mod_concatx 模块
这种编译方式会自动安装Apache模块,安装成功后,可以在Apache 模块目录找到 mod_concatx.so,并且 conf/httpd.conf 配置也会加上 mod_concatx 模块信息
启动Apache
注:Apache启动后,以后台服务运行。如果想关闭Apache, 就使用以下命令:
查看已加载的Apache模块
说明mod_concatx已加载!
找到占用端口的Pid,kill掉即可。
加多一行记录-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT保存后,重启防火墙。
2015/6/11 补充Linux下Apache无法正常运行的解决办法
2016/8/16 更新mod_concatx.c的地址(google code已下架)
参考:http://blog.csdn.net/mycwq/article/details/46426261
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... Apachechecking for working mkdir -p... yeschecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuconfigure:configure: Configuring Apache Portable Runtime library...configure:checking for APR... noconfigure: error: APR not found. Please read the documentation. |
编译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 |
$ 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 |
$ 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 |
$ ./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 --no-check-certificat https://raw.githubusercontent.com/chenweiqi/apmod/master/mod_concatx/mod_concatx.c$ ln -s /usr/local/apache/bin/apxs /usr/local/bin/apxs$ apxs -c mod_concatx.c |
$ apxs -iac mod_concatx.c |
启动Apache
$ /usr/local/apache/bin/httpd -k start |
$ /usr/local/apache/bin/httpd -k stop |
$ /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) |
Apache无法正常运行的解决办法
1. 80端口被占用
$ netstat -anp | grep :80 |
2. 防火墙默认禁用80端口
$ vi /etc/sysconfig/iptables |
$ service iptables restart |
2016/8/16 更新mod_concatx.c的地址(google code已下架)
参考:http://blog.csdn.net/mycwq/article/details/46426261
相关文章推荐
- Apache安全配置
- apache常用命令整理
- 用 Apache Tika 理解信息内容
- centos下利用yum安装LAMP(Linux+Apache+MySQL+PHP)及配置
- linux 下 apache启动、停止、重启命令
- apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for
- 利用ubuntu 14.04+apache+modsecurity实现云WAF
- [转] Web性能压力测试工具之ApacheBench(ab)详解
- [转] Ubuntu 12.04下LAMP安装配置 (Linux+Apache+Mysql+PHP)
- Linux下Apache配置局域网访问出现的问题
- apache rewrite与options multiviews不得不说的秘密
- Apache启动提示错误undefined symbol: libiconv_open解决方法
- mac + apache + php
- Apache启用URL重写模块
- 五种开源协议的比较(BSD,Apache,GPL,LGPL,MIT)
- Ubuntu下关闭apache和mysql的开机启动
- Windows下PHP5.6.9+Apache2.4的安装配置
- PHP学习之[第02讲]PHP5.4 Apache Mysql 搭配与多站点配置详解
- Web学习-apache视图log刊物
- 利用 org.apache.commons.io.FileUtils快速读写文件