Centos7安装httpd2.4.46

1. 安装环境

#安装编译环境
yum install gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel expat-devel

2. 升级openssl

因为httpd2.4.46需要openssl v1.1.1版本。centos7yum仓库的版本太老不支持

#下载openssl,解压
 wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1h.tar.gz
tar xvf openssl-1.1.1h.tar.gz
#编译安装到指定目录/app/openssl下
cd ~/openssl-1.1.1h
./config --prefix=/app/openssl
make && make install
#配置环境
echo "/app/openssl/lib/" >> /etc/ld.so.conf
ldconfig -v
echo 'export PATH=/app/openssl/bin:$PATH' > /etc/profile.d/openssl.sh
. /etc/profile.d/openssl.sh

3. 升级apr包

这也是最新版httpd的要求不然编译的时候会报错。

#下载apr包,解压
wget https://mirror.dsrg.utoronto.ca/apache//apr/apr-1.7.0.tar.bz2
tar xvf apr-1.7.0.tar.bz2
cd apr-1.7.0
#编译安装
./configure --prefix=/usr/
make && make install

4.升级apr-util

#跟上面一下下载,解压
wget https://mirror.dsrg.utoronto.ca/apache//apr/apr-util-1.6.1.tar.bz2
tar xvf apr-util-1.6.1.tar.bz2
#编译安装
./configure --prefix=/app/util --with-apr=/usr/bin/apr-1-config --enable-utf8
make && make install

5. 安装httpd

上面的环境升级完后才可进行这一步,不然会报错的。

#下载包,解压
wget https://mirror.its.dal.ca/apache//httpd/httpd-2.4.46.tar.bz2
tar xvf  httpd-2.4.46.tar.bz2
cd httpd-2.4.46
#编译安装到/app/httpd24目录
./configure --prefix=/app/httpd24/
make && make install

6. 配置

  • 报错:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

解决方案:
找到#ServerName www.example.com:80 把#去掉,然后改成 ServerName 127.0.0.1:80再重啟apache即可沒事了。

7. 参考链接

参考链接
参考链接

原文地址:https://www.cnblogs.com/98record/p/centos7an-zhuanghttpd2446.html