sudo yum install yum-utils
vi /etc/yum.repos.d/nginx.repo
输入:
[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
yum-config-manager --enable nginx-mainline
yum install nginx
ps -ef | grep nginx
systemctl enable nginx
systemctl start nginx
默认的html根目录在:/usr/share/nginx/html
默认的配置文件在:/etc/nginx/conf.d/default.conf 以及 /etc/nginx/nginx.conf