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
安裝apr
[root@hanshuo local]# mkdir -p apr
[root@hanshuo local]# cd src
[root@hanshuo src]# tar -xvf apr-1.7.0.tar.gz
[root@hanshuo src]# cd apr-1.7.0
[root@hanshuo apr-1.7.0]# ./configure --prefix=/usr/local/apr
編輯configure找到$RM "$cfgfile"将其注釋掉即可
[root@hanshuo apr-1.7.0]# make & make install
[root@hanshuo local]# mkdir -p apr-util
[root@hanshuo local]# cd src
[root@hanshuo src]# ls
apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.46.tar.gz openssl-1.1.1h openssl-1.1.1h.tar.gz php-7.2.4.tar.gz
[root@hanshuo src]# tar -xvf apr-util-1.6.1.tar.gz
[root@hanshuo src]# cd apr-util-1.6.1
[root@hanshuo apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
[root@hanshuo apr-util-1.6.1]# make & make install
[root@hanshuo local]# mkdir -p apache2
[root@hanshuo local]# cd src
[root@hanshuo src]# tar xvf httpd-2.4.46.tar.gz
[root@hanshuo src]# cd httpd-2.4.46
[root@hanshuo httpd-2.4.46]# ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@hanshuo httpd-2.4.46]# make
[root@hanshuo httpd-2.4.46]# make install
[root@hanshuo httpd-2.4.46]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e4cf:1261:bd34:cebc%ens33. Set the 'ServerName' directive globally to suppress this message
[root@hanshuo httpd-2.4.46]# cd /usr/local/apache2
[root@hanshuo apache2]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules