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配置与测试的更多相关文章

  1. Windows下Nginx配置SSL实现Https访问(包含证书生成)

    Vincent.李   Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...

  2. Windows下nginx配置多台服务器做负载均衡

    Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一个IMAP/POP3/SMTP服务. Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3 ...

  3. windows 下nginx配置php支持

    修改nginx配置 location ~ \.php$ { root D:/Learn/php/test/; fastcgi_pass ; fastcgi_index index.php; fastc ...

  4. windows 下 nginx 配置虚拟主机

    1. 在 nginx 的配置文件 nginx.conf 里面 引入虚拟主机配置文件,以后所有的虚拟主机配置文件都在写这个文件里 include       vhost.conf; (或者新建vhost ...

  5. windows 下nginx配置ssl https支持

    本文适合正式上线的配置,购买来的证书 私钥*.key文件需要先去掉密码 openssl rsa -in old.key -out new.key

  6. Windows下Nginx Virtual Host多站点配置详解

    Windows下Nginx Virtual Host多站点配置详解 此教程适用于Windows系统已经配置好Nginx+Php+Mysql环境的同学. 如果您还未搭建WNMP环境,请查看 window ...

  7. (转)windows 下安装配置 Nginx 详解

    windows 下安装配置 Nginx 详解 本文转自https://blog.csdn.net/kingscoming/article/details/79042874 nginx功能之一可以启动一 ...

  8. Windows下phpstudy配置tp5的nginx时遇到的奇葩问题

    nginx原来的配置: hosts已经配置好127.0.0.1 到tpdev1.net这个域名 最后结果 No input file specified. 解决方法: 找到原因了,竟然是root的分隔 ...

  9. windows下nginx的启动关闭

    Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍. .启 ...

随机推荐

  1. zookeeper使用和原理探究(一)(转)

    zookeeper介绍zookeeper是一个为分布式应用提供一致性服务的软件,它是开源的Hadoop项目中的一个子项目,并且根据google发表的<The Chubby lock servic ...

  2. [liu yanling]软件测试技巧

    1.添加.修改功能 (1)是否支持tab键 (2)是否支持enter键 (3)不符合要求的地方是否有错误提示 (4)保存后,是否也插入到数据库中 (5)字段唯一的,是否可以重复添加 (6)对编辑页列表 ...

  3. 关于 Unity UI 中 GraphicRaycaster.Raycast 数量巨大的问题

    有时候会发现 Unity UI 非常耗时,在 Profiler 中可以轻易的看到 UI 中 的 GraphicRaycaster.Raycast 单帧调用可以成百上千,甚至好几千,帧速率前不忍赌,一关 ...

  4. 关于NSLocalizedString(@"Foo %@",nil)

    NSLocalizedString(@"Foo %@",nil) 这句话实际上是在多语言文件中寻找一个key为“Foo %@”的文字,千万不要把这个和[NSString strin ...

  5. 五指cms安装说明

    1.五指cms目录结构说明 |-- coreframe                   #框架目录 |   |-- app                     #模块(应用程序)目录 |    ...

  6. git引用^和~的区别

    这篇git文章必转:解答我一直的疑惑 http://www.cnblogs.com/hutaoer/archive/2013/05/14/3078191.html 一. 引子 在git操作中,我们可以 ...

  7. Codeforces Round #226 (Div. 2)C. Bear and Prime Numbers

    /* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数. */ #include <stdio.h ...

  8. Dynamics CRM 2011 2013-(An error occurred while opening mailbox xxx@xx.com Microsoft.Crm.Tools.Email.Providers.)

    An error occurred while opening mailbox  Microsoft.Crm.Tools.Email.Providers. Whenever I check how C ...

  9. poj 2325 Persistent Numbers (贪心+高精度)

    把输入数字每次从9-2除,能整除则记录该数字,最后从小到大输出. 应该算是水题,不过窝第一次写高精度除法,虽然1A,不过中间改了好多次. /****************************** ...

  10. nyoj 915 +-字符串

    +-字符串 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同.Shiva一次可以把一个加号和它相邻的减号交换. ...