nginx安装和目录结构介绍

一、本机实验环境

本次实验环境,单机。本地测试虚拟机:

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

二、配置nginx官方yum源直接安装nginx

nginx官方稳定版本yum仓库配置说明地址:
http://nginx.org/en/linux_packages.html#stable

根据自己环境配置的最终配置:

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# cat nginx.repo 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

配置好yum仓库的配置文件后,执行以下命令:
(1) 查看nginx的官方repo是否已经存在

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
repo id                                                       repo name                                                        status
base/7/x86_64                                                 CentOS-7 - Base                                                  9,911
extras/7/x86_64                                               CentOS-7 - Extras                                                  434
nginx/x86_64                                                  nginx repo                                                         124
updates/7/x86_64                                              CentOS-7 - Updates                                               1,614
repolist: 12,083
[root@localhost ~]# yum repolist|grep 'nginx'
nginx/x86_64                        nginx repo                              124

(2)查看yum仓库中关于nginx的安装包(我这里是已经安装过了的)

[root@localhost ~]# yum list|grep 'nginx'
nginx.x86_64                                1:1.14.1-1.el7_4.ngx       @nginx   
nginx-debug.x86_64                          1:1.8.0-1.el7.ngx          nginx    
nginx-debuginfo.x86_64                      1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-geoip.x86_64                   1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-geoip-debuginfo.x86_64         1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-image-filter.x86_64            1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-image-filter-debuginfo.x86_64  1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-njs.x86_64                     1:1.14.1.0.2.5-1.el7_4.ngx nginx    
nginx-module-njs-debuginfo.x86_64           1:1.14.1.0.2.5-1.el7_4.ngx nginx    
nginx-module-perl.x86_64                    1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-perl-debuginfo.x86_64          1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-xslt.x86_64                    1:1.14.1-1.el7_4.ngx       nginx    
nginx-module-xslt-debuginfo.x86_64          1:1.14.1-1.el7_4.ngx       nginx    
nginx-nr-agent.noarch                       2.0.0-12.el7.ngx           nginx    
pcp-pmda-nginx.x86_64                       3.12.2-5.el7               base 

(3) yum安装nginx

yum -y install nginx

三、nginx目录层级介绍

(1) 确认nginx软件包的安装

[root@localhost ~]# rpm -qa|grep nginx
nginx-1.14.1-1.el7_4.ngx.x86_64

(2) 查看nginx软件包的安装列表文件

[root@localhost ~]# rpm -ql nginx
/etc/logrotate.d/nginx
/etc/nginx
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/modules
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx
/usr/lib64/nginx/modules
/usr/libexec/initscripts/legacy-actions/nginx
/usr/libexec/initscripts/legacy-actions/nginx/check-reload
/usr/libexec/initscripts/legacy-actions/nginx/upgrade
/usr/sbin/nginx
/usr/sbin/nginx-debug
/usr/share/doc/nginx-1.14.1
/usr/share/doc/nginx-1.14.1/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx

(3) nginx安装文件和目录层级说明

[root@localhost ~]# rpm -ql nginx
/etc/logrotate.d/nginx    #nginx日期切割脚本(被rsyslog托管)
/etc/nginx				  #nginx的配置文件主目录
/etc/nginx/conf.d		  #附加配置文件目录
/etc/nginx/conf.d/default.conf  #nginx初始提供的默认子配置文件
/etc/nginx/fastcgi_params  #定义了一些与fastcgi协议有关的变量的配置文件
/etc/nginx/koi-utf			#与编码相关的配置文件(不懂就保持默认,不要随便更改和删除)
/etc/nginx/koi-win			#与编码相关的配置文件(不懂就保持默认,不要随便更改和删除)
/etc/nginx/mime.types		#nginx的mime文件(定义文件类型和映射关系的,具体涉及到http相应报文中的属性值)
/etc/nginx/modules          #nginx模块文件安装路径(是一个链接文件,实际指向/usr/lib64/nginx/modules)
/etc/nginx/nginx.conf		#nginx的主配置文件
/etc/nginx/scgi_params		#定义了一些与scgi协议有关的变量的配置文件
/etc/nginx/uwsgi_params     #定义了一些与uwsgi协议有关的变量的配置文件
/etc/nginx/win-utf			#与编码相关的配置文件(不懂就保持默认,不要随便更改和删除)
/etc/sysconfig/nginx		#定义一些与nginx有关变量设置的配置文件(可能与管理脚本有关的配置文件)
/etc/sysconfig/nginx-debug  #定义了nginx运行与调试模式下,与nginx有关变量设置的配置文件(可能与管理脚本有关的配置文件)
/usr/lib/systemd/system/nginx-debug.service	#托管于systemd管理的运行与调试模式下的服务脚本(nginx调试模式的unit文件)
/usr/lib/systemd/system/nginx.service		#托管于systemd管理的nginx的服务脚本(nginx的unit文件)
/usr/lib64/nginx							#nginx模块文件主目录
/usr/lib64/nginx/modules					#nginx的模块文件目录
/usr/libexec/initscripts/legacy-actions/nginx  #nginx自己提供一些功能脚本目录(特殊作用的)
/usr/libexec/initscripts/legacy-actions/nginx/check-reload  #检测nginx服务载入是否异常的脚本
/usr/libexec/initscripts/legacy-actions/nginx/upgrade   #与nginx升级相关的脚本
/usr/sbin/nginx								#nginx主程序文件
/usr/sbin/nginx-debug						#nginx运行于调试模式下的住程序文件
/usr/share/doc/nginx-1.14.1					#nginx的文档路径
/usr/share/doc/nginx-1.14.1/COPYRIGHT		#版权说明相关的配置文件
/usr/share/man/man8/nginx.8.gz				#nginx的man手册文件
/usr/share/nginx							#nginx的默认站点路径
/usr/share/nginx/html						#nginx默认提供的html文件的路径
/usr/share/nginx/html/50x.html				#50x状态码相应的html文件
/usr/share/nginx/html/index.html            #默认的主页文件
/var/cache/nginx							#nginx缓存相关的路径
/var/log/nginx								#nginx的日志记录的路径

参考文档地址:http://nginx.org/en/docs/

ps:nginx其他知识点待续…

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章