<p>yum install -y nginx</p><p>通过yum安装的时候提示下面的错误</p><p>[root@localhost yum.repos.d]# yum install nginx</p><p>已加载插件:fastestmirror, langpacks</p><p>Loading mirror speeds from cached hostfile</p><p>没有可用软件包 nginx。</p><p>错误:无须任何处理</p><p>需要添加nginx的源</p><p>[root@localhost yum.repos.d]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm</p><p>该命令执行之后,会在/etc/yum.respos.d下面多出一个nginx.repo</p><p>[root@localhost yum.repos.d]# ll</p><p>总用量 40</p><p>-rw-r–r–. 1 root root 1572 12月&nbsp; 1 2016 CentOS-Base.repo</p><p>-rw-r–r–. 1 root root 1572 12月&nbsp; 1 2016 CentOS-Base.repo.backup</p><p>-rw-r–r–. 1 root root 1664 10月 24 10:36 CentOS-Base.repo.bak</p><p>-rw-r–r–. 1 root root 1309 8月&nbsp; 30 2017 CentOS-CR.repo</p><p>-rw-r–r–. 1 root root&nbsp; 649 8月&nbsp; 30 2017 CentOS-Debuginfo.repo</p><p>-rw-r–r–. 1 root root&nbsp; 314 8月&nbsp; 30 2017 CentOS-fasttrack.repo</p><p>-rw-r–r–. 1 root root&nbsp; 630 8月&nbsp; 30 2017 CentOS-Media.repo</p><p>-rw-r–r–. 1 root root 1331 8月&nbsp; 30 2017 CentOS-Sources.repo</p><p>-rw-r–r–. 1 root root 3830 8月&nbsp; 30 2017 CentOS-Vault.repo</p><p>-rw-r–r–. 1 root root&nbsp; 113 7月&nbsp; 15 2014 nginx.repo</p><p>然后再执行安装命令</p><p>yum install -y nginx</p><p>安装之后,可以查看nginx的默认安装目录</p><p>[root@localhost yum.repos.d]# whereis nginx</p><p>nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz</p><p>[root@localhost yum.repos.d]# pwd</p><p>/etc/yum.repos.d</p><p>以下是Nginx的默认路径:</p><p>(1) Nginx配置路径:/etc/nginx/</p><p>(2) PID目录:/var/run/nginx.pid</p><p>(3) 错误日志:/var/log/nginx/error.log</p><p>(4) 访问日志:/var/log/nginx/access.log</p><p>(5) 默认站点目录:/usr/share/nginx/html</p><p>事实上,只需知道Nginx配置路径,其他路径均可在/etc/nginx/nginx.conf 以及/etc/nginx/conf.d/default.conf 中查询到</p><p>nginx相关的验证命令及启动命令</p><p>[root@localhost yum.repos.d]# nginx&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>[root@localhost yum.repos.d]# nginx -t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok</p><p>nginx: configuration file /etc/nginx/nginx.conf test is successful</p><p>[root@localhost yum.repos.d]# nginx -s reload&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>nginx&nbsp; &nbsp;启动</p><p>nginx -t&nbsp; 测试命令</p><p>nginx -s relaod 修改nginx.conf之后,可以重载</p><p>&nbsp;</p><p><br/></p>