vi /etc/yum.repo.d/nginx.repo #創(chuàng)建repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存退出
yum install nginx -y #yum安裝nginx
防火墻設置
firewall-cmd --zone=public --add-service=http --permanent #添加規(guī)則
firewall-cmd --reload #重新加載防火墻
Nginx服務配置
systemctl start nginx #啟動nginx服務
systemctl enable nginx #啟動自啟
systemctl stop nginx #關(guān)閉服務