1.下载解压Apache需要的依赖包
Arp下载:
# wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
# tar zxvf apr-1.7.0.tar.gz
arp-util下载:
# wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
# tar zxvf apr-util-1.6.1.tar.gz
pcre下载:
# wget https://sourceforge.net/projects/pcre/files/pcre/8.43/pcre-8.43.tar.gz
# tar zxvf pcre-8.43.tar.gz
httpd下载:
# wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
# tar zxvf httpd-2.4.39.tar.gz
2.安装gcc及gcc-c++
# yum install gcc
# yum install gcc-c++
3.安装apr
# cd apr-1.7.0
# ./configure --prefix=/usr/local/apr
# Make
# Make install
# Cd ..
4.安装apr-util
# cd apr-util-1.6.1
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
# yum install -y expat-deve* //apr-util1.6.1缺少expat-deve*库,make时会报错
# Make
# Make install
# Cd ..
5.安装prce
# cd pcre-8.43
# ./configure --prefix=/usr/local/pcre-8.43
# Make
# Make install
# Cd ..
6.安装httpd
# cd httpd-2.4.39
# ./configure --prefix=/usr/local/apache --with-pcre=/usr/local/pcre-8.43 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
# Make
# Make install
7.开启apache服务
#/usr/local/apache/bin/apachectl start //注:此处可能报错‘ServerName’,简单解决办法将主机名改为localhost