-----------------------------------------------
========
windows 下 安装 nginx
========
1 博文地址
https://www.cnblogs.com/qfb620/p/5508468.html
-------------
2 下载地址
http://nginx.org/en/download.html
找nginx-1.8.1 pgp 并下载
解压路径
F:\Tool\112Nginx\nginx-1.8.1\nginx-1.8.1
-------------
3 cd到指定路径进行安装
定位目录
cd F:\Tool\112Nginx\nginx-1.8.1\nginx-1.8.1
安装
start nginx.exe
查看所有进程列表,如果有两个 nginx.exe 说明 安装成功
tasklist
tasklist /fi "imagename eq nginx.exe"
检测8080端口是否被占用
netstat -ano | findstr 0.0.0.0:80
进入nginx欢迎页,有 Welcome to nginx 说明 nginx 启动成功
http://127.0.0.1
查看nginx的错误日志
F:\Tool\112Nginx\nginx-1.8.1\nginx-1.8.1\logs\error.log
-------------
常用 nginx(.exe可加,可不加)命令 (cmd窗口要到 nginx.exe 所在的路径下才能找到 nginx.exe 命令)
启动
start nginx.exe
停止
nginx.exe -s stop
退出
nginx.exe -s quit
重新载入配置文件(此命令执行成功时没有任何输出,执行失败会提示失败原因)
nginx.exe -s reload
查看 nginx 版本
nginx.exe -v
-------------
nginx 配置文件
F:\Tool\112Nginx\nginx-1.8.1\nginx-1.8.1\conf\nginx.conf
nginx 配置文件详细解释
https://www.2cto.com/os/201212/176520.html
-------------
-----------------------------------------------
========
使用 nginx 代理服务器 做 负载均衡
========
博文地址
https://www.cnblogs.com/jiangwangxiang/p/8481661.html
1
配置 nginx 的配置文件 nginx.conf,客户端达到nginx代理服务器(监听80端口)时 跳转到 指定目标服务器的目的,
通过 proxy_pass 配置请求转发地址
2
具体细节实现 参见 nginxForWindows.vsdx
3
nginx 代理服务器的地址
http://localhost:80/user-web/jsonAction/queryCifStatus.json
nginx 代理服务器 所 代理的服务地址
http://localhost:9901/user-web/jsonAction/queryCifStatus.json
http://172.16.23.51:80/user-web/jsonAction/queryCifStatus.json
http://172.16.23.51:9901/user-web/jsonAction/queryCifStatus.json
-------------
========
使用 nginx 代理服务器 做 静态资源服务器配置
========
1 静态资源(jpg|png|js|css等)放到 nginx 的 static 目录下
2 nginx.conf 配置文件 的 location / 中(备注:静态资源只能放在 location / 中) 配置如下
#反向代理的配置 配置静态资源
location /static{
#静态资源根路径,备注:root的值不能以 \ 结尾,否则 nginx 在 reload 时报错,而且 分隔符必须 是 /
#nginx代理服务器访问url路径: http://localhost/static/anu.png
#实际磁盘访问路径 F:/Tool/112Nginx/nginx-1.8.1/nginx-1.8.1/static/anu.png
root F:/Tool/112Nginx/nginx-1.8.1/nginx-1.8.1;
}
备注:static是自己新建的文件夹
3 往 static 目录下放入 anu.png 图片
代理服务器url地址: http://localhost/static/anu.png
访问的静态资源路径: F:/Tool/112Nginx/nginx-1.8.1/nginx-1.8.1/static/anu.png
-----------------------------------------------