在CentOS 7.9上安装Nginx可以通过EPEL仓库来进行。以下是安装Nginx的步骤:
1.首先,添加EPEL仓库:
sudo yum install epel-release
2. 然后,通过EPEL仓库安装Nginx:
sudo yum install nginx
3.安装完成后,启动Nginx服务:
sudo systemctl start nginx
4.(可选)设置Nginx开机自启动:
sudo systemctl enable nginx
5.(可选)通过防火墙允许HTTP和HTTPS流量:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
6.检查Nginx服务的状态,确保其正在运行:
sudo systemctl status nginx
7.现在,你可以通过浏览器访问服务器的公网IP或域名来验证Nginx安装是否成功。如果安装成功,你将看到Nginx的欢迎页面。