到 cd /etc/yum.repos.d/ 目錄下
新建nginx.repo 文件nginx
vim nginx.repovim
輸入如下信息centos
[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
經過yum search nginx看看是否已經添加源成功。若是成功則執行下列命令安裝nginx。url
yum install -y nginx
rest
3、啓動nginxcode
service nginx start service nginx stop service nginx restart
nginx -v
io
nginx version: nginx/1.16.1
service nginx start
table