一、安装Apache
Apache在默认的CentOS仓库中可用,安装非常简单。 在CentOS和RHEL上,Apache软件包和服务称为httpd。 要安装软件包,请运行以下命令:
sudo yum install httpd

安装完成后,启用并启动Apache服务:
sudo systemctl enable httpd

检查防火墙状态和版本
sudo systemctl start httpd

检查apache版本
sudo httpd -v

验证Apache是否安装成功,浏览器中打开您的服务器IP地址http://YOUR_IP,您将看到默认的Apache欢迎页面,如下所示:说明Apache安装成功

使用systemctl管理Apache服务
我们可以像任何其他系统单元一样管理Apache服务。
要停止Apache服务,请运行:
sudo systemctl stop httpd
要再次启动,请键入:
sudo systemctl start httpd
重新启动Apache服务:
$sudo systemctl restart httpd
在进行一些配置更改后重新加载Apache服务:
$sudo systemctl reload httpd
如果您想禁用Apache服务以在启动时启动:
$sudo systemctl disable httpd
并重新启用它:
$sudo systemctl enable httpd

参考链接:
https://www.linuxidc.com/Linux/2018-05/152261.htm |