nginx的功能
1.web服务器
2.反向代理(proxy)
3.stream server
http的概念
url的分解:
协议://账号:密码@主机:端口号(可以省略)/路径?请求内容(field=value)#关键字
https://www.jianshu.com:8080/writer#/notebooks/43071819/notes/60957101
http事务
request(请求)请求方法,域名地址,html版本
reponse(响应)
status code:
2xx:成功 3xx:重定位 4xx:客户端未响应 5xx:服务器端错误
httpd MPM
1.prefork:进程模型,主进程生成子进程,由子进程响应请求
2.worker:线程模型,主进程生成线程,由线程来响应请求
3.event:时间驱动模型:主进程成功事件,有事件来响应请求
题外话(I/O模型)
阻塞型,非阻塞型,复用型,信号驱动型,异步

nginx是复用型调用:

正向代理和方向代理(集群采用的都是正向代理的思想)

nginx的架构

master/worker组合进程
master进程(一个):负载加载和分析配置文件、管理worker进程,平滑升级
worker(一个或多个):处理并响应用户请求
缓存相关进程:cache loader /cache manager
特性:异步,事件驱动,非阻塞
并发处理请求epoll
nginx模块
模块分类(core,http,mail,streams)
nginx功能
1.静态web服务器反向请求
2.fastcgi反代资源请求
3.tcp/ip 请求转发
nginx基本操作
1.yum info nginx 查看nginx信息
2.ss -tnl 查看端口是否来了(主要看80端口)
3.查看nginx有哪些文件
[root@localhost ~]# rpm -ql nginx
/etc/nginx/fastcgi.conf
/etc/nginx/fastcgi.conf.default
/etc/nginx/fastcgi_params
/etc/nginx/fastcgi_params.default
/etc/nginx/nginx.conf #原始配置文件位置
/etc/nginx/nginx.conf.default
/usr/bin/nginx-upgrade
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx/modules
/usr/sbin/nginx
/usr/share/nginx/html/404.html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html
/var/lib/nginx
/var/lib/nginx/tmp
/var/log/nginx
4.查看nginx命令
[root@localhost nginx]# nginx -h
nginx version: nginx/1.16.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload(很重要,平缓升级主要靠他)
-p prefix : set prefix path (default: /usr/share/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
网友评论