最新消息:七维网络改版啦,域名www.7dwww.com

源码包安装Apache 环境:Linux(CentOS)

未分类 sevennet 1537浏览 0评论

1、依赖关系 

 httpd依赖于apr, apr-util

httpd-2.4 依賴于1.5+及以上版本的apr (yum list apr 看了一下没有1.5以上版本的,所以也采用源码包安装)

apr源码包下载地址:https://apr.apache.org/download.cgi

同时还依赖

gcc , prce, prce-devel, openssl, openssl-devel ,这几个采用yum 安装rpm包即可。

2、安装

首先yum安装rpm包

# yum install -y gcc pcre pcre-devel openssl openssl-devel

下载apr,apr-util, httpd

#wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.3.tar.gz

#wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

#wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.33.tar.bz2

解压 

#tar -xzf 包文件

安装apr

# ./configure –prefix=/usr/local/apr   (–prefix指定apr安装的目录)

# make

# make  install

安装apr-util

# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr

# make

# make  install

安装httpd

以下为几个主要的配置项

–sysconfdir=/etc/httpd24  指定配置文件路径

–enable-so  启动模块动态装卸载

–enable-ssl 编译ssl模块

–enable-cgi 支持cgi机制(能够让静态web服务器能够解析动态请求的一个协议)

–enable-rewrite  支持url重写    

–with-zlib  支持数据包压缩     

–with-pcre  支持正则表达式

–with-apr=/usr/local/apr  指明依赖的apr所在目录

–with-apr-util=/usr/local/apr-util/  指明依赖的apr-util所在的目录

–enable-modules=most      启用的模块

–enable-mpms-shared=all   以共享方式编译的模块

–with-mpm=prefork         指明httpd的工作方式为prefork

#./configure –prefix=/usr/local/apache –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –sysconfdir=/etc/httpd24  –enable-so  –enable-ssl –enable-cgi –enable-rewrite –with-zlib  –with-pcre –enable-modules=most

#make

#make install

3、启动,停止

#/usr/local/apache24/bin/apachectl start (启动apache)

#/usr/local/apache24/bin/apachectl stop (停止apache)

4、将Apache加入到系统服务里面: 

  #cp /安装目录下/apache/bin/apachectl /etc/rc.d/init.d/httpd 

  修改httpd 

  在文件头部加入如下内容: 

  ### 

  # Comments to support chkconfig on RedHat Linux 

  # chkconfig: 2345 90 90 

  # description:http server 

  ### 

  保存 

  在打入 

  #chkconfig –add httpd 

  #chkconfig –level 345 httpd on  

关于安装中会出现的一些错误,主要是依赖没有做好,下面列举一些例子

错误信息: 
*checking for APR… no 
configure: error: APR not found. Please read the documentation.* 
解决方案:安装apr 并在配置文件中指定安装路径 如:–with-apr=/usr/local/apr

错误信息: 

*checking for APR-util… no 

configure: error: APR-util not found. Please read the documentation.*

解决方案: 下载安装 并在配置文件中指定安装路径 如:–with-apr-util=/usr/local/apr-util

错误信息:

*checking for pcre-config… false 

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/* 

解决方案:还是少环境安装 PCRE 

错误信息:

fatal error: apr_escape.h: No such file or directory

 #include “apr_escape.h”

安装的apr版本太低,找个高版本的装上,并在配置文件中指定安装路径 如:–with-apr=/usr/local/apr

转载请注明:七维网络 » 源码包安装Apache 环境:Linux(CentOS)

头像
发表我的评论
取消评论

Captcha Code

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址