Centos 7 下Apache的源码安装
安装的前提是:已经安装好Centos 7系统,安装前最好先检查一下是否有旧版本的Apache,如果有尽量卸载
首先,我需要下载最新版的zlib和Apache,使用命令:
wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz 下载zlib
wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.17.tar.gz 下载Apache
安装之前我们需要先检查gcc和g++是否安装,如果没有,使用一下命令安装:
yum -y install gcc
安装g++有所不同:
yum -y install gcc-c++
1.需要先安装 zlib:
- [root@xt test]# tar -zxf zlib-1.2.8.tar.gz
- [root@xt test]# cd zlib-1.2.8
- [root@xt zlib-1.2.8]# ./configure --prefix=/usr/local/apr
- [root@xt zlib-1.2.8]# make && make install
2.安装Apache:
- [root@xt test]# tar -zxf httpd-2.4.17.tar.gz
- [root@xt test]# cd httpd-2.4.17
- [root@xt httpd-2.4.17]# ./configure \
--prefix=/usr/local/apache2 \
--with-z=/usr/local/zlib/ \
--sysconfdir=/etc/htttpd \
--disable-userdir \
--enable-so \
--enable-rewrite=shared \
--enable-expires=shared \
--enable-deflate=shared \
--enable-static=suppert \ - [root@xt httpd-2.4.17]# make && make install
理论上执行完这个命令Apache的安装就已经完成了,但是在centos 7中会报一个错误:
configure: error: APR not found . Please read the documentation
解决办法:
1.下载所需软件包:
- wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
- wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
- wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
2.编译安装:
- yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
具体步骤如下:
a:解决apr not found问题>>>>>>
- [root@xt test]# tar -zxf apr-1.4.5.tar.gz
- [root@xt test]# cd apr-1.4.5
- [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr
- [root@xt apr-1.4.5]# make && make install
b:解决APR-util not found问题>>>>
- [root@xt test]# tar -zxf apr-util-1.3.12.tar.gz
- [root@xt test]# cd apr-util-1.3.12
- [root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config
- [root@xt apr-util-1.3.12]# make && make install
c:解决pcre问题>>>>>>>>>
- [root@xt test]#unzip -o pcre-8.10.zip
- [root@xt test]#cd pcre-8.10
- [root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre
- [root@xt pcre-8.10]#make && make install
4.最后编译Apache时加上:
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre