添加yum源:nginx
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
安裝:shell
yum -y install nginx
centos
啓動服務:url
/bin/systemctl start nginx.servicespa
設置開機自動啓動: code
ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'get
/bin/systemctl enable nginx.service it
配置文件地址:
class
/etc/nginx
配置
訪問主機地址便可見到nginx首頁,若是啓動成功而不能訪問,請檢查防火牆設置。
參考文獻: