centos 安装 apache
- 更新系统
首先,我们需要更新系统,以确保安装的所有软件都是最新的版本。在终端中运行以下命令:
sudo yum update
- 安装 Apache
在 CentOS 中,我们可以使用 yum 命令很容易地安装 Apache。
sudo yum install httpd
- 启动 Apache
完成安装后,我们可以启动 Apache 服务。在终端中运行以下命令:
sudo systemctl start httpd
- 设置开机启动
如果您想让 Apache 在系统启动时自动启动,可以运行以下命令:
sudo systemctl enable httpd
- 防火墙设置
默认情况下,CentOS 7 防火墙会阻止对 Apache 的访问。如果您希望其他人能够访问您的网站,您需要打开防火墙的 HTTP 和 HTTPS 端口。
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
- 测试 Apache
现在,您可以在浏览器中输入服务器的 IP 地址来测试 Apache 是否已正确安装。如果您看到 Apache 的默认欢迎页面,则说明一切正常。
http://your_server_ip_address/
至此,CentOS 上的 Apache 安装完成
原文地址: http://www.cveoy.top/t/topic/hv2r 著作权归作者所有。请勿转载和采集!