進入nginx官網:[http://nginx.org/en/linux_packages.html#stable],找到下圖(http://nginx.org/en/linux_packages.html#stable)
新建一個nginx.repo,修改上圖標識出來的內容,保存
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
查看nginx 列表:未新建nginx.repo時:
yum list | grep nginx
查看nginx 列表:新建nginx.repo後:
yum 安裝:
yum install nginx -y
完成安裝:
查看nginx 版本:小寫v
nginx -v
查看nginx參數:大寫v
nginx -V
啓動 systemctl start nginx
停止 systemctl stop nginx
重啓 syatemctl restart nginx
訪問localhost或者ip