windows下Nginx配置与测试
1.获取
下载地址:http://nginx.org/en/download.html
参考网址:http://nginx.org/en/docs/windows.html
2.准备工作,IIS创建俩个测试网站,参考截图:

两个网站的地址分别是(我本地的地址是192.168.31.233),两个网站的名称分别是端口的名称,故两个网站的地址分别是 192.168.31.233:8087和192.168.31.233:8088
3.nginx配置 (解压之后 的conf文件夹中的 nginx.conf文件)
【解压路径放置到 非中文路径,建议不要有空格,之前测试rabbitmq的时候,也遇到很多坑其实都是因为空格和中文路径】
#user nobody;
#指定nginx进程数量
worker_processes ; #全局错误日志以及 PID文件
#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 { #设定http服务器,利用它的反向代理功能提供均衡负载支持
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 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用,
sendfile on;
#tcp_nopush on; #连接超时时间
#keepalive_timeout ;
keepalive_timeout ; #开启gzip压缩
#gzip on; #设定负载均衡的服务器列表 支持多组的负载均衡,可以配置多个upstream 来服务于不同的Server.
#nginx 的 upstream 支持 几 种方式的分配
#)、轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。
#)、weight 指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。 跟上面样,指定了权重。
#)、ip_hash 每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题。
#)、fair
#)、url_hash #Urlhash
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
#.down 表示单前的server暂时不参与负载
#.weight 默认为1.weight越大,负载的权重就越大。
#.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
#server 192.168.31.233 down;
#server 192.168.31.233 backup;
server 192.168.31.233: weight=;
server 192.168.31.233: weight=;
} #配置代理服务器的地址,即Nginx安装的服务器地址、监听端口、默认地址
server {
#.侦听80端口
listen ; #对于server_name,如果需要将多个域名的请求进行反向代理,可以配置多个server_name来满足要求
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
# 默认主页目录在nginx安装目录的html子目录。
root html;
index index.html index.htm;
proxy_pass http://mysvr; #跟载均衡服务器的upstream对应
} #error_page /.html; # redirect server error pages to the static page /50x.html
## 定义错误提示页面
#error_page /50x.html;
#location = /50x.html {
# root html;
#} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
4.启动nginx
cmd cd到解压目录, 执行 start nginx运行 nginx

然后是通过 tasklist /fi "imagename eq nginx.exe"判断是否运行成功。
这时候就可以访问 server中的指定的 server_name和监听的 端口地址,比如我这边 监听端口是 8086,所以我的访问地址是 http://localhost:8086/
这时候可以发现不停的刷新页面的时候,指向的地址在 8088和8087之间的两个网站在不停的切换。
注意:因为是使用 IIS,IIS默认端口是80,我之所以换成 8086也是为了避免这个问题。
windows下Nginx配置与测试的更多相关文章
- Windows下Nginx配置SSL实现Https访问(包含证书生成)
Vincent.李 Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...
- Windows下nginx配置多台服务器做负载均衡
Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一个IMAP/POP3/SMTP服务. Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3 ...
- windows 下nginx配置php支持
修改nginx配置 location ~ \.php$ { root D:/Learn/php/test/; fastcgi_pass ; fastcgi_index index.php; fastc ...
- windows 下 nginx 配置虚拟主机
1. 在 nginx 的配置文件 nginx.conf 里面 引入虚拟主机配置文件,以后所有的虚拟主机配置文件都在写这个文件里 include vhost.conf; (或者新建vhost ...
- windows 下nginx配置ssl https支持
本文适合正式上线的配置,购买来的证书 私钥*.key文件需要先去掉密码 openssl rsa -in old.key -out new.key
- Windows下Nginx Virtual Host多站点配置详解
Windows下Nginx Virtual Host多站点配置详解 此教程适用于Windows系统已经配置好Nginx+Php+Mysql环境的同学. 如果您还未搭建WNMP环境,请查看 window ...
- (转)windows 下安装配置 Nginx 详解
windows 下安装配置 Nginx 详解 本文转自https://blog.csdn.net/kingscoming/article/details/79042874 nginx功能之一可以启动一 ...
- Windows下phpstudy配置tp5的nginx时遇到的奇葩问题
nginx原来的配置: hosts已经配置好127.0.0.1 到tpdev1.net这个域名 最后结果 No input file specified. 解决方法: 找到原因了,竟然是root的分隔 ...
- windows下nginx的启动关闭
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍. .启 ...
随机推荐
- ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
- HDU-1240 Asteroids! (BFS)这里是一个三维空间,用一个6*3二维数组储存6个不同方向
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission ...
- Frame 处理
# -*- coding:utf-8 -*- """ 通过 id 或 name 识别处理 fram 框架 """ from selenium ...
- oracle rac logminer有限制用法及session_info为unknown情况
这里只记录下有条件的情况如何使用 BEGIN dbms_logmnr.start_logmnr( dictfilename => '/u01/arch/logminer_dict.ora', ...
- What's the difference between all the Selection Segues
relationship -A "relationship" segue is the segue between a container view controller and ...
- mysql均衡负载
一.利用mysql 复制分流查询操作: 利用mysql的主从复制可以有效的分流更新操作和查询操作,具体的实现是一个主服务器,承担更新操作,多台从服务器,承担查询操作,主从之间通过复制实现数据的同步.多 ...
- PC-大概最全的黑客工具表了
纯真IP数据库查询程序 remote administrator (rar解密)ZiperelloV2.0 汉化版.zip (代理跳板)SkSockServer1.09.zip [ar ...
- makeKeyAndVisible的功能
makeKeyAndVisible的作用 [self.window makeKeyAndVisible] 由于iPhone是单窗口程序,所以也就只有这么一个Window对象,而且是UIWindow,不 ...
- 【三支火把】---一份程序看懂C程序printf()的几种常用用法
闲来继续巩固我的学习之路,今天略微整理了一下,C程序中Printf()的一些常用用法,虽然自己以前好像会,但是不够系统,今天大致整理了一些,先贴上来看看,以后在看到其他,继续补充,希望能帮到一些像我一 ...
- jbpm4.4 demo2
package cn.itcast.b_processdefinition; import java.io.FileInputStream; import java.io.FileOutputStre ...