sudo yum install yum-utils
vi /etc/yum.repos.d/nginx.repo
將下列內容寫入nginx.repo文件中nginx
[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 module_hotfixes=true [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 module_hotfixes=true
sudo yum install nginx -y
說明:-y 爲忽略問詢選項自動安裝,若要接受步驟問詢可不帶本參數centos
sudo systemctl start nginx.service