一、yum安装apache
yum -y install httpd
二、启动apache服务及设置开机启动
systemctl start httpd
systemctl enable httpd
三、设置防火墙允许apache端口(关闭跳过此操作)HTTP=80、HTTPS=443
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
重启防火墙
firewall-cmd --reload
四、检查apache服务的状态及版本
状态Active: active (running)代表已启动
[root@123 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2021-01-15 14:42:27 CST; 23s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 1845 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 6
CGroup: /system.slice/httpd.service
├─1845 /usr/sbin/httpd -DFOREGROUND
├─1847 /usr/sbin/httpd -DFOREGROUND
├─1848 /usr/sbin/httpd -DFOREGROUND
├─1849 /usr/sbin/httpd -DFOREGROUND
├─1850 /usr/sbin/httpd -DFOREGROUND
└─1851 /usr/sbin/httpd -DFOREGROUND
1月 15 14:42:26 zabbix-web systemd[1]: Starting The Apache HTTP Server...
1月 15 14:42:27 zabbix-web httpd[1845]: AH00558: httpd: Could not reliably determine the server's fully qua...ssage
1月 15 14:42:27 zabbix-web systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
版本
[root@123 ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 16 2020 16:18:20
五、验证安装是否成功
在浏览器输入服务器IP地址,端口默认是80所以不用输入,如果有改动就需要输入IP:端口
systemctl管理Apache服务命令
systemctl stop httpd ------关闭
systemctl start httpd ------开启
systemctl restart httpd ------重启
systemctl disable httpd ------禁止开机启动
systemctl enable httpd ------开机启动