1. 连接Xshell,配置ip,关闭防火墙(systemctl stop firewalld),关闭内核机制(setenforce 0)
2. 把在官网下载的压缩包拖到Xshell终端里,需要的包(httpd-2.4.50.tar.gz)
包都在我主页的资源里
3. md5sum httpd-2.4.50.tar.gz
4. rpm -q httpd
mkdir /media/cdrom
mount /dev/sr0 /media/cdrom
cd /etc/yum.repos.d
mkdir bak
mv C* bak
cp bak/CentOS-Media.repo ./
vim CentOS-Media.repo
cd
5. yum clean all && yum makecache
6. yum install -y gcc gcc-c++ make apr-util-devel pcre-devel
echo $?
7. tar zxvf httpd-2.4.50.tar.gz -C /usr/src
echo $?
cd /usr/src/httpd-2.4.50
8. ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
echo $?
make
9. make install
echo $?
cd /usr/local/httpd
10. ln -s /usr/local/httpd/bin/* /usr/local/bin
echo $PATH
11. vim /lib/systemd/system/httpd.service
[Unit] Description=The Apache httpd service After=network.target
[Service] Type=forking PIDFILE=/usr/local/httpd/logs/httpd.pid ExecStart=/usr/local/httpd/bin/apachectl $OPTIONS ExecReload=/bin/kill -HUP $MAINPID
[Install] WantedBy=multi-user.target
12. systemctl daemon-reload
13. systemctl enable httpd
14. cd /usr/local/httpd/conf
15. cp /usr/local/httpd/conf/httpd.conf{ , . bak}
16. vim httpd.conf
202行 ServerName www.kgc.om:80
echo $PATH
17. apachectl -t
18. systemctl start httpd
19. netstat -anpt |grep httpd
20. vim /etc/hosts
192.168.10.10 www.kgc.com
去本机浏览器上验证