Nginx服务
- 1.Nginx
- 01.Nginx介绍
- 1.基础概念:
- 2.网站服务特性:
- 3.软件功能特性:
- 4.nginx与apache的区别
- 5.Nginx企业应用
- 02.Nginx网站服务部署
- 1.Nginx网站服务软件部署方式
- 2.Nginx网站服务软件安装部署过程
- 3.Nginx配置文件
- 4.主配置文件/etc/nginx/nginx.conf
- 5.扩展配置文件/etc/nginx/conf.d/*.conf
1.Nginx
01.Nginx介绍
1.基础概念:
2.网站服务特性:
01.支持高并发 02.资源消耗特性 03.负载均衡特性 04.数据缓存特性 05.异步网络特性
3.软件功能特性:
01.支持网站页面请求处理功能
02.支持反向代理负载均衡功能
03.支持前端业务数据缓存功能
4.nginx与apache的区别
①. epoll模型与select模型对比比喻:宿舍管理大妈
②. epoll模型与select模型对比比喻:幼儿园的阿姨
nginx:异步模型 epoll
apache:同步模型 select
5.Nginx企业应用
01.静态服务应用场景(浏览缓存应用…)
02.代理服务应用场景 (反向代理,负载均衡…)
03.安全服务应用场景(流量限制,拦截SQL注入…)
04.流行框架应用场景(Nginx+PHP(Fastcgi_pass)LNMP,Nginx+Java(Proxy_pass)LNMT,Nginx+Python(uwsgi_pass)LNMP)
02.Nginx网站服务部署
1.Nginx网站服务软件部署方式
源码安装 官方仓库安装 rpm包安装
2.Nginx网站服务软件安装部署过程
3.Nginx配置文件
[root@web01 ~]# rpm -ql nginx
/etc/logrotate.d/nginx \\\nginx日志切割的配置文件/etc/nginx/etc/nginx/nginx.conf \\\nginx主配置文件 /etc/nginx/conf.d/etc/nginx/conf.d/default.conf \\\nginx.conf一样 /etc/nginx/mime.types \\\媒体类型 (http协议中的文件类型)/etc/nginx/fastcgi_params/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/modules/etc/nginx/scgi_params/etc/nginx/uwsgi_params/etc/nginx/win-utf
/etc/sysconfig/nginx \\\systemctl 管理 nginx的使用的文件/usr/lib/systemd/system/nginx.service \\\systemctl 管理nginx(开 关 重启 reload) 配置文件 /usr/sbin/nginx \\\nginx命令
/usr/sbin/nginx-debug/usr/share/nginx/html \\\站点目录 网站的根目录 www.oldboyedu.com/oldboy.jpg
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx \\\nginx日志 access.log 访问日志
/etc/nginx/nginx.conf配置的详解
4.主配置文件/etc/nginx/nginx.conf
[root@web01 /etc/nginx]# cat nginx.conf
---下面有些内容我改动过
user www;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {worker_connections 2048;
}
http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65;#gzip on;
#include /etc/nginx/conf.d/www.conf;include /etc/nginx/conf.d/*.conf; ---这一行最重要,/etc/nginx/conf.d/*.conf 这个文件里面有域名,端口号,Nginx站点目录,站点目录里面放的就是前端代码或者图片等等
}
5.扩展配置文件/etc/nginx/conf.d/*.conf
[root@web01 /etc/nginx/conf.d]# cat www.conf ---www.conf是自己可以改的名字
server {listen 80; ---端口号server_name www.oldboy.com; ---域名location / {root /usr/share/nginx/html; ---Nginx站点目录index index.html; ---网站首页文件}
}