---
title: "linux 下 源代码 安装 apache"
author: "conkeyn"
date: "2012-09-29T08:05:22Z"
tags: []
categories: ["操作系统"]
slug: "linux-apache"
draft: false
lastmod: "2012-10-23T09:44:23Z"
id: 1688321
url: "https://conkeyn.iteye.com/blog/1688321"
---

1、安装openssl  
tar -zxf openssl-1.0.0c.tar.gz  
cd openssl-1.0.0c/  
./config threads shared zlib-dynamic --prefix=/usr/local --openssldir=/usr/local/ssl  
make clean  
make && make install

cp libcrypto.pc /usr/local/lib/pkgconfig  
chmod 644 /usr/local/lib/pkgconfig/libcrypto.pc  
cp libssl.pc /usr/local/lib/pkgconfig  
chmod 644 /usr/local/lib/pkgconfig/libssl.pc  
cp openssl.pc /usr/local/lib/pkgconfig  
chmod 644 /usr/local/lib/pkgconfig/openssl.pc

2、安装PCRE(Perl Compatible Regular Expressions中文含义：perl语言兼容正则表达式)是一个用C语言编写的正则表达式函数库  
tar xzvf pcre-8.31.tar.gz  
cd pcre-8.31  
./configure --prefix=/usr/local/pcre-8.31 --libdir=/usr/local/lib/pcre \\  
\--includedir=/usr/local/include/pcre --enable-unicode-properties

make && make install

3、安装zlib  
$tar -xvzf zlib-1.2.3.tar.gz  
$cd zlib-1.2.3.tar.gz  
$./configure  
$make  
$sudo make install

zlib的默认安装位置：  
cp libz.a /usr/local/lib  
chmod 644 /usr/local/lib/libz.a  
cp libz.so.1.2.7 /usr/local/lib  
chmod 755 /usr/local/lib/libz.so.1.2.7  
cp zlib.3 /usr/local/share/man/man3  
chmod 644 /usr/local/share/man/man3/zlib.3  
cp zlib.pc /usr/local/lib/pkgconfig  
chmod 644 /usr/local/lib/pkgconfig/zlib.pc  
cp zlib.h zconf.h /usr/local/include  
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h

4、apr-util,下载编译apr-util之后，继续编译apache

.configure --prefix=/root/soft/apache --with-apr=/root/soft/apr/ --with-apr-util=/root/soft/apr-util/

2、到apache官方网站 http://httpd.apache.org/download.cgi 下载最新版本的apache,然后解压，执行如下命令：  
./configure "--prefix=/usr/local/apache2.4.3" \\  
"--with-apr=/usr/local/apr-1-4-6/bin/apr-1-config" \\  
"--with-apr-util=/usr/local/apr-util/bin/apu-1-config" \\  
"--with-pcre=/usr/local/pcre-8.31/bin/pcre-config" \\  
"--with-ssl=/usr/local/ssl/" \\  
"--with-z=/usr/local/lib" \\  
\--enable-cache --enable-file-cache --enable-disk-cache \\  
\--enable-mime-magic --enable-headers --enable-ssl --enable-http \\  
\--enable-rewrite --enable-so

make && make install

提示：configure: error: APR not found. Please read the documentation.

2：提示缺少apr,下载http://apache.freelamp.com/apr/ ，编译安装完成apr之后，继续编译apache.

3：编译( ./configure --prefix=/root/soft/apr-util –with-apr=/root/soft/apr)

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

4:缺少

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

8、出现了一个问题  
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message  
解决：  
\[root@linux bin]# vi /server/apache/conf/httpd.conf  
修改ServerName www.example.com:80 为 ServerName localhost:80

编译安装 mod\_jk  
完成以上设定后，即可开始编译 mod\_jk。  
root # cd tomcat-connectors-1.2.26-src/native/  
root # ./configure --with-java-home=/usr/local/jdk1.6.0\_35 --with-apxs=/usr/local/apache2.4.3/bin/apxs  
root # make