-
下载源码包(建议去官网直接下载源码包,速度快很多)
# 迅雷下载很快,下载地址:https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz
curl -o httpd-2.4.52.tar.gz https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz
-
解压源码包到指定目录
tar zxf httpd-2.4.52.tar.gz -C /usr/src
-
检查编译环境
gcc --version
yum -y install gcc
make --version
yum -y install make
-
下载依赖
# 一次性下载4个依赖包
yum -y install apr-devel apr-util apr-util-devel pcre-devel
-
切换目录进行配置
# 进入配置目录
cd /usr/src/httpd-2.4.52
./configure --prefix=/usr/local/apach
-
进行编译安装
make
make install
-
修改配置文件,添加自己的虚拟机域名
vim /usr/local/apach/conf/httpd.conf
# 输入关键字进行查找
/ServerName
# 在#ServerName www.example.com:80下面添加一行,格式如下:
ServerName 192.168.112.112:80
-
关闭防火墙,并启动
# 关闭防火墙
systemctl stop firewalld
# 启动httpd服务
/usr/local/apach/bin/apachectl start