1.下载源码包上传到linux中

2.编译源码包安装apache软件
安装软件:yum install gcc gcc-c++ make -y
解压:tar xf httpd-2.4.62.tar.bz2 -C /usr/local/src/

指定组和用户:groupadd -r -g 48 apache
useradd -r -u 48 -g 48 -c "Apache server" -s /sbin/nologin apache
在 /usr/local/src/httpd-2.4.62目录下使用
./configure --prefix=/usr/local/apache
根据最下方的报错信息安装依赖

yum install -y apr-devel

继续使用./configure --prefix=/usr/local/apache并根据报错信息安装依赖
再次使用./configure --prefix=/usr/local/apache并根据报错信息安装依赖
现在就编译安装完成了

然后执行make和 make install
3.启动脚本
进入目录:cd /usr/local/apache/bin
cp apachectl /etc/init.d/httpd
在httpd文件中加入两行
#chkconfig: 35 80 10
#description: Apache is an HTTP(S) server

添加成系统服务:
chkconfig --level 35 --add httpd
设置开机自启:
chkconfig --level 35 httpd on
查看

第二种方式:
清除之前配置
chkconfig --level 35 httpd off
chkconfig --level 35 --del httpd
rm -f /etc/init.d/httpd
创建文件
vim /usr/lib/systemd/system/httpd.service

修改.conf文件用户,组
vim /usr/local/apache/conf/httpd.conf
