#安装前准备:关闭防火墙和SELinux
#1 安装相关包
[root@centos8 ~]#dnf install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
#2 下载并解压缩包
[root@centos8 ~]#wget https://dlcdn.apache.org//httpd/httpd-2.4.46.tar.bz2
[root@centos8 ~]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src
#3 配置
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.46/ [root@centos8 httpd-2.4.46]#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl
#4 编译并安装
[root@centos8 httpd-2.4.46]#make -j 4 && make install
#5 配置环境
[root@centos8 ~]#echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh [root@centos8 ~]#. /etc/profile.d/httpd.sh
#6 运行
[root@centos8 ~]#apachectl start
#7 指定用apache用户运行
[root@centos8 ~]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache [root@centos8 ~]#vim /etc/httpd/httpd.conf user apache group apache
#8 配置生效和验证
[root@centos8 ~]#apachectl restart
#9 查看进程
[root@centos8 ~]#ps aux|grep apache
#10 用浏览器打开以下地址http://10.0.0.150,验证apache服务