#使用yum工具安裝Apache
[root@Centos8 ~]# yum install -y httpd
#使用systemctl start命令啓動httpd服務
[root@Centos8 ~]# systemctl start httpd
#使用systemctl status命令查看httpd服務
[root@Centos8 ~]# systemctl status httpd
#命令systemctl enable可設置某服務爲開機自啓動。
#命令systemctl disable可設置某服務爲開機不自動啓動。
[root@Centos8~]# systemctl enable httpd.service
出現下圖所示的active,證明成功了。
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