在CentOS镜像中安装和配置Web服务器,可选择Apache或Nginx,以下是具体步骤:
安装Apache
- 更新系统:
sudo yum update -y。 - 安装Apache:
sudo yum install -y httpd。 - 启动服务并设置开机自启:
sudo systemctl start httpd,sudo systemctl enable httpd。 - 配置防火墙:
sudo firewall-cmd --permanent --add-service=http,sudo firewall-cmd --permanent --add-service=https,sudo firewall-cmd --reload。
安装Nginx
- 安装EPEL仓库:
sudo yum install epel-release。 - 安装Nginx:
sudo yum install nginx。 - 启动服务并设置开机自启:
sudo systemctl start nginx,sudo systemctl enable nginx。 - 配置防火墙(同Apache)。
以上步骤参考自,可根据实际需求进一步配置虚拟主机、SSL证书等。