centos7 安装nginx

一、 yum install nginx找不到源
1、下载对应当前系统版本的nginx包(package)

# wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2、建立nginx的yum仓库

# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm    

3、下载并安装nginx

# yum install nginx

4、启动nginx服务

systemctl start nginx

5、访问localhost
如果访问不了,可能是防火墙设置问题,执行如下命令:

sudo firewall-cmd --permanent --zone=public --add-service=http  
sudo firewall-cmd --permanent --zone=public --add-service=https 
sudo firewall-cmd --reload
原文地址:https://www.cnblogs.com/cglWorkBook/p/5618353.html