CentOS7源码包安装apache

一、下载apache源码包
1.下载地址:http://httpd.apache.org/download.cgi,下载 httpd-2.4.20.tar.gz
2.上传到服务器目录,/tmp/
解压:tar -zxvf httpd-2.4.20.tar.gz
进入目录:cd httpd-2.4.20
3.编译刚刚解压的源文件,
配置编译参数:
./configure –prefix=/usr/local/apache24/ (配置安装目录 /usr/local/apache24/)
4.正常执行 (说明你的linux安装过apache,或者已经安装了所需的依赖包。)
make
make install
错误信息:
*checking for APR… no
configure: error: APR not found. Please read the documentation.*
解决方案:
二、安装apr
Apache在安装时需要一些准备环境,这里需要安装另外一个东西 APR(Apache Portable Runtime)。

下载地址: http://archive.apache.org/dist/apr/ 同样找最新版本
得到文件:apr-1.5.2.tar.gz
解压:tar -zxvf apr-1.5.2.tar.gz
cd /usr/local/installers/apr-1.5.2    
 ./configure --prefix=/usr/local/apr/   
make 
make install 


完成后在指定地址生成目录和文件

三、尝试安装apache
接着装apache,切换到源代码目录设置编译参数: ./configure –prefix=/usr/local/apache24/

还是报上面的错,
        *checking for APR... no
        configure: error: APR not found.  Please read the documentation.*
        解决方案:
这是因为上面自定义了apr的安装目录,所以得把这个信息告诉apache。
./configure --prefix=/usr/local/apache24/  --with-apr=/usr/local/apr/  

错误信息:
*checking for APR-util… no
configure: error: APR-util not found. Please read the documentation.*

解决方案: 下载 APR-util
下载地址:http://archive.apache.org/dist/apr/ 找最新版本

得到文件:apr-util-1.5.4.tar.gz

解压: tar -zxvf apr-util-1.5.4.tar.gz

编译:
    cd /usr/local/installers/apr-util-1.5.4  

     ./configure --prefix=/usr/local/apr-util/   
这次运行会报错:
    checking for APR... no
    configure: error: APR could not be located. Please use the --with-apr option.
看到提示你就懂了,--with-apr:
    ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/  

     make  

     make install   
    在你指定的安装地址生成目录就说明安装成功了

四. 继续安装apache
切到apache源代码目录下运行:
./configure –prefix=/usr/local/apache/ –with-apr=/usr/local/apr/ –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
下载地址: http://jaist.dl.sourceforge.net/project/pcre/pcre/ 找最新版下

得到文件: pcre-8.37.tar.gz

解压:tar -zxvf pcre-8.37.tar.gz

编译:
    cd /usr/local/hunter/installers/pcre-8.37  

    ./configure --prefix=/usr/local/pcre/  
这次错误信息如下:
    *checking for windows.h... no
    configure: error: You need a C++ compiler for C++ support.*
解决方案:
    yum -y install gcc-c++

五. 继续apache的安装,一定要在参数中带上以上3种环境配置:
./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
/usr/local/apache24/bin/apachectl start (启动apache)

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

你可能感兴趣的:(linux)