#使用yum工具安装Apache
[root@Centos8 ~]# yum install -y httpd
#使用systemctl start命令启动httpd服务
[root@Centos8 ~]# systemctl start httpd
#使用systemctl status命令查看httpd服务
[root@Centos8 ~]# systemctl status httpd
出现下图所示的active,证明成功了。
#命令systemctl enable可设置某服务为开机自启动。
#命令systemctl disable可设置某服务为开机不自动启动。
[root@Centos8~]# systemctl enable httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service /usr/lib/systemd/system/httpd.service.
#使用systemctl list-unit-files命令确认httpd服务是否已配置为开机自启动
[root@Centos8~]# systemctl list-unit-files | grep httpd.service
如果是failed,查看是否是端口号引起的错误,并进行修改。
强制卸载Apache的方法:rpm -e httpd –nodeps