需要添加nginx的源

cd /etc/yum.repo/ rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装nginx

yum install nginx -y

以下是Nginx的默认路径:

Nginx配置路径:/etc/nginx/ PID目录:/var/run/nginx.pid 错误日志:/var/log/nginx/error.log 访问日志:/var/log/nginx/access.log 默认站点目录:/usr/share/nginx/html 事实上,只需知道Nginx配置路径,其他路径均可在/etc/nginx/nginx.conf 以及/etc/nginx/conf.d/default.conf 中查询到

启动与关闭

systemctl start nginx 启动 systemctl stop nginx 关闭 nginx -t 查看有没有错误