CentOS 7 安装Nginx

本文安装官方网站的教程安装 https://nginx.org/en/linux_packages.html#RHEL-CentOS

1、To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

  新建/etc/yum.repos.d/nginx.repo

  写入

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

 

2、By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

  由于默认用的不是稳定版本,可以使用命令 

1 sudo yum-config-manager --enable nginx-mainline

切换到稳定版本

3、To install nginx, run the following command:

1 sudo yum install nginx

When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

安装过程中注意核对证书

 

启动nginx

1 systemctl start nginx

 

posted @ 2019-05-27 20:55  子兰  阅读(198)  评论(0编辑  收藏  举报