环境准备
Linux发行版本:Centos7
增加nginx yum源
- 进入到yum源配置目录,创建文件nginx.repo,增加yum源信息
[admin@localhost yum.repos.d]$ cd /etc/yum.repos.d
[admin@localhost yum.repos.d]$ vim nginx.repo
[admin@localhost yum.repos.d]$ cat 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
安装Nginx
现在Nginx yum源已经安装在您的服务器上,使用以下yum命令安装Nginx :
[admin@localhost yum.repos.d]$ sudo yum install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirror.jdcloud.com
* updates: ap.stykers.moe
nginx-stable | 2.9 kB 00:00:00
nginx-stable/7/x86_64/primary_db | 50 kB 00:00:03
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.16.1-1.el7.ngx will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================