记一次阿里云配置源码Apache

在阿里云上源码配置Apache,还是遇到很多问题。不过还好都是解决了,所以想写一篇博客来帮助大家配置Apache.

阿里云服务器配置 Centos 6.8

首先来看看阿里云官方配置Apache教程
这看起来很简单 但是其实有很多坑
首先先按官网的下载和解压Apache的源码包

这是我遇到的其中几个问题

  • checking for APR… no
    configure: error: APR not found. Please read the documentation.

  • checking for APR-util… no
    configure: error: APR-util not found. Please read the documentation.

  • configure: error: APR-util not found. Please read the documentation.
    checking for pcre-config… false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

  • checking for OpenSSL version >= 0.9.8a… FAILED configure: WARNING: OpenSSL version is too old no checking whether to enable mod_ssl… configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

所以要提前安装APR , APR-util, pcre, Openssl
首先下载这些包的源码

wget http://us.mirrors.quenda.co/apache//apr/apr-util-1.6.1.tar.gz
wget http://us.mirrors.quenda.co/apache//apr/apr-1.6.3.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1-pre8.tar.gz

APRAPR-util都是可以在Apache官网找到的 最好安装最新版本
Pcre最新源码包在这里
Openssl源码包在这里

安装这些源码包的步骤都是相似

扫描二维码关注公众号,回复: 2731964 查看本文章

tar -xvzf apr-1.6.3.tar.gz
tar -xvzf apr-util-1.6.1.tar.gz
tar -xvzf pcre-8.42.tar.gz
tar -xvzf openssl-1.1.1-pre8.tar.gz

这里注意,为了方便之后使用,请在/usr/local/目录下创建对应的文件夹 比如apr/和apr-util/和pcre/还有openssl/

然后在各自的文件夹中运行

./configure –prefix=/usr/local/当前你的目录名
make & make install

这里有个很坑的事情,在我安装Pcre的时候出现了这个错误

pcre Invalid C++ compiler or C++ compiler flags

后来才发现原来我服务器连g++都没有…..
而centos如果安装g++不可以用sudo yum install g++ 而要使用下面

sudo yum install gcc-c++

现在终于到了最后安装Apache的时候了,进入了httpd的目录

./configure –prefix=/usr/local/apache/httpd –enable-ssl=static –with-ssl=/usr/local/openssl –with-apr-util=/usr/local/apr-util –with-pcre=/usr/local/pcre

在阿里云官方给的命令中加入了3个with 然后成功编译.

configure: summary of build options:

    Server Version: 2.4.33
    Install prefix: /usr/local/apache/httpd
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:
    LIBS:
    C preprocessor: gcc -E

最后在运行

make & make install

运行httpd -v查看安装版本.

猜你喜欢

转载自blog.csdn.net/helloworld19970916/article/details/81059299