打开 Nginx 官网选择相要下载的版本:

选择下载已经构建好的Linux对应系统版本:

利用 yum 来安装,需要先更新安装源:

  • CentOS 6.x
1
2
3
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
chmod +x nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -i nginx-release-centos-6-0.el6.ngx.noarch.rpm
  • CentOS 7.x
1
2
3
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
chmod +x nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -i nginx-release-centos-7-0.el7.ngx.noarch.rpm

会有警告key的信息,不用理会已经安装成功

开始安装:

1
yum install nginx

检查版本:

1
2
nginx -v
nginx version: nginx/1.8.0