1.nginx的下载

解压后文件目录:

2.nginx的常用命令

nginx -s stop 强制关闭
 nginx -s quit 安全关闭
 nginx -s reload 改变配置文件的时候,重启nginx工作进程,来时配置文件生效
 nginx -s reopen 打开日志文件

3.nginx的核心:nginx.conf配置文件

#运行nginx的所属组和所有者
#user nobody; #表示工作进程的数量,一般设置为cpu的核数
worker_processes ; #错误日志路径
#error_log logs/error.log; #error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
#表示每个工作进程的最大连接数
worker_connections ;
} http {
#文件MIME(Content-Type) 映射表
include 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 logs/access.log main; sendfile on;
#tcp_nopush on; #超时时间
keepalive_timeout ; #gzip on; #设置负载均衡的服务器列表
upstream my_stream {
#weigth参数表示权值,权值越高被分配到的几率越大
server 127.0.0.1: weight=;
server 127.0.0.1: weight=;
} #server{}块定义了虚拟主机,一个server段一般对应一个域名
server {
listen ; #监听域名
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
#root指定对应uri的资源查找路径,这里html为相对路径
root html; #指定首页index文件的名称,可以配置多个,以空格分开。如有多个,按配置顺序查找
index index.html index.htm;
} #error_page /404.html; # redirect server error pages to the static page /x.html
#
#定义错误页
error_page /x.html;
location = /x.html {
root html;
}
} #第二个server
server {
listen ;
server_name localhost;
location / { root html; index index_.html index_.htm;
} #对php后缀的请求进行负载均衡
location ~ .*\.php$ {
...
#请求转向my_stream中的服务器列表,进行负载均衡
proxy_pass http://my_stream ; ...
} #设置查看Nginx状态的地址 访问:localhost:/ngnix_status
#active connections – 活跃的连接数量
#server accepts handled requests — 总共处理了个连接 , 成功创建次握手, 总共处理了个请求
#reading — 读取客户端的连接数.
#writing — 响应数据到客户端的数量
#waiting — Nginx 已经处理完正在等候下一次请求指令的驻留连接.
location /ngnix_status {
stub_status on;
access_log off;
}
} }

4.顺带:localhost,127.0.0.1,本机IP之间的差异

localhost 不联网 不使用网卡,不受防火墙和网卡限制 本机访问

127.0.0.1 不联网 网卡传输,受防火墙和网卡限制 本机访问

本机IP 联网 网卡传输 ,受防火墙和网卡限制 本机或外部访问

最新文章

  1. Java异常处理机构(日常笔记)
  2. 阿里云 esc 云服务器无缘无故的一次/usr/bin 目录丢失导致整个服务无法启动 # ./shutdown.sh ./shutdown.sh: line 41: dirname:command not found cannot find /catalina.sh the find /catalina.sh The file is absent or does not have execute
  3. PLSQL 逻辑多线程机制
  4. 【JSP jstl c标签】使用c:foreach 报错(警告)”test does not support runtime expressions“
  5. LeetCode | Unique Paths【摘】
  6. Android手机分辨率基础知识(DPI,DIP计算)
  7. oracle创建自增长列
  8. 组合View Controller时遇到的一点问题
  9. Docker外部访问容器
  10. spring依赖注入之构造函数注入,set方法注入
  11. vmware安装CentOS开发环境搭建
  12. Codeforces 1131F Asya And Kittens (构造)【并查集】
  13. 关于Segmentation fault (core dumped)
  14. es_5.4.4 reinstall log and upgrade to V6.5.4--APM
  15. [代码]--其他信息: ORA-01400: 无法将 NULL 插入
  16. 输入控件tagsinput
  17. npm saveError ENOENT: no such file or directory
  18. 16:42 python历史
  19. vim文本处理技巧
  20. python自动化之读写

热门文章

  1. 《Web 前端面试指南》1、JavaScript 闭包深入浅出
  2. 虾扯蛋:Android View动画 Animation不完全解析
  3. 微信小程序体验(2):驴妈妈景区门票即买即游
  4. MVC5+EF6+MYSQl,使用codeFirst的数据迁移
  5. CSS垂直居中的11种实现方式
  6. JavaScript 常量定义
  7. WCF基础
  8. Maven 整合FreeMarker使用
  9. SQL 数据优化索引建suo避免全表扫描
  10. Linux基础介绍【第一篇】