---
title: "Linux下Apache的安装"
author: "sailqi"
date: "2012-04-23T22:37:00Z"
tags: ["Apache", "Linux"]
categories: ["企业架构"]
slug: "linux-apache"
draft: false
lastmod: "2015-06-12T13:17:28Z"
id: 1638219
url: "https://sailqi.iteye.com/blog/1638219"
---

**一、软件环境**  
1、系统：CentOS release 5.6  
2、Apache：httpd-2.4.2.tar.bz2  
3、依赖包：  
apr-1.4.6.tar.bz2、apr-util-1.4.1.tar.bz2（下载地址：[http://apr.apache.org/download.cgi](http://apr.apache.org/download.cgi)）  
pcre-8.30.tar.bz2（下载地址：[http://www.pcre.org](http://www.pcre.org)）

假设所需软件包放于：/root/software/

**二、安装过程**

1、安装apr

#cd /root/software  
#tar -jxvf apr-1.4.6.tar.bz2  
#cd apr-1.4.6  
#./configure  
#make  
#make install

2、安装apr-util

#cd /root/software  
#tar -jxvf apr-util-1.4.1.tar.bz2  
#cd apr-util-1.4.1  
#./configure --with-apr=/usr/local/apr  
#make  
#make install

 

3、安装pcre

#cd /root/software  
#tar -jxvf pcre-8.30.tar.bz2  
#cd pcre-8.30  
#./configure -prefix=/usr/local/pcre/  
#make  
#make install

4、安装apache

#cd /root/software  
#tar -jxvf httpd-2.4.2.tar.bz2  
#cd httpd-2.4.2  
#./configure -prefix=/usr/local/apache -enable-so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/ --with-pcre=/usr/local/pcre/  
#make  
#make install

**三、运行**  
1、进入/usr/local/apache/conf，将httpd.conf中：  
#ServerName www.example.com:80  
改为：  
ServerName localhost:80

2、进入/usr/local/apache/bin，执行#./apachectl start

3、在浏览器输入ip地址即可访问。

**四、遇到问题**  
1、C编译器  
描述：no acceptable C compiler found in $PATH  
See \`config.log' for more details  
解决：#yum intall gcc

2、C++编译器  
描述：unrecognized option \`-DHAVE\_CONFIG\_H'  
解决：#yum install gcc-c++

3、apr-util路径  
注意apr-util与apr安装路径相同，与网上某些资料有差异。

**五、参考资料**  
[http://www.kuitao8.com/?p=34](http://www.kuitao8.com/?p=34)  
[http://www.linlook.com/detail\_MTI5Mw==.html](http://www.linlook.com/detail_MTI5Mw==.html)  
[http://www.linuxdiyf.com/viewarticle.php?id=273174](http://www.linuxdiyf.com/viewarticle.php?id=273174)