官网提供的 RHEL/CentOS 安装方法
1:先添加nginx yum源,分为稳定版和开发版,复制其中一个
2:新建 nginx.repo 文件,添加上面复制的源并保存
[root@localhost etc]# vim /etc/yum.repos.d/nginx.repo
3:保存后查看是否添加成功,输入 yum list | grep nginx 命令
[root@localhost yum.repos.d]# yum list | grep nginx
nginx.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx-stable
nginx-debuginfo.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-geoip.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-geoip-debuginfo.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-image-filter.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-image-filter-debuginfo.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-njs.x86_64 1:1.16.1.0.3.5-1.el7.ngx nginx-stable
nginx-module-njs-debuginfo.x86_64 1:1.16.1.0.3.5-1.el7.ngx nginx-stable
nginx-module-perl.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-perl-debuginfo.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-xslt.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-module-xslt-debuginfo.x86_64 1:1.16.1-1.el7.ngx nginx-stable
nginx-nr-agent.noarch 2.0.0-12.el7.ngx nginx-stable
pcp-pmda-nginx.x86_64 4.1.0-5.el7_6 updates
4:然后直接使用 yum install nginx 安装命令进行安装即可
[root@localhost yum.repos.d]# yum install nginx
5:安装完成后使用 nginx -v 即可查看当前安装nginx版本
[root@localhost yum.repos.d]# nginx -v
nginx version: nginx/1.16.1
nginx安装目录功能讲解
使用 rpm -ql nginx 命令查看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.16.1
/usr/share/doc/nginx-1.16.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
Nginx日志轮转,用于logrotate服务的日志切割:
/etc/logrotate.d/nginx
nginx主配置文件:
/etc/nginx
/etc/nginx/nginx.conf
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
cgi配置相关,fastcgi配置:
/etc/nginx/fastcgi_params
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
编码转换映射转化文件:
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/win-utf
设置http协议的Content-Type与扩展名对应关系:
/etc/nginx/mime.types
用于配置出系统守护进程管理器管理方式:
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
nginx服务的启动管理的终端命令:
/usr/sbin/nginx
/usr/sbin/nginx-debug
nginx模块目录:
/etc/nginx/modules
/usr/lib64/nginx/modules
nginx的手册和帮助文件:
/usr/share/doc/nginx-1.16.1
/usr/share/doc/nginx-1.16.1/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
nginx的缓存目录:
/var/cache/nginx
nginx的日志目录:
/var/log/nginx