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. Shell获取文件后缀名

    file = "thisfile.txt" echo "filename: ${file%.*}" echo "extension: ${file## ...

  2. Android中TextView输入字数统计和限制

    在Android开发应用的时候,文本编辑框中最多输入140个字,经常会显示还剩多少字以限制用户输入的字数, EditText content;//定义一个文本输入框 TextView hasnum;/ ...

  3. [King.yue]关于CSLA框架的一些看法

    CSLA.Net 是一个有帮助的成熟开发框架,但不适于初学者.该框架支持在任何地方.任何时间创建对象,值得我们花时间去学习了解这一框架.CSLA.Net 框架设计的业务对象,支持对完全透明的数据源进行 ...

  4. 搭建Windows Azure开发环境-环境搭建

    虚拟机中运行 练习1:使用远程桌面连接到虚拟机 在本节中,你会登录到Windows Azure的门户网站,并使用Windows Azure库创建的Azure虚拟机. 任务1 -配置的Visual St ...

  5. 《Android View 的事件分发和滑动冲突》 —预习资料

    1. 阅读书籍<Android开发艺术探索>第三章 2. 提前阅读如下技术文章: http://blog.csdn.net/singwhatiwanna/article/details/3 ...

  6. test-from

    title header1 hahhahjl header2 adfkljasd $$a^2$$ point 1 point 2 | table1 | table2 | | ---- | ---- | ...

  7. Centos kvm桥接

    新建一个ifcfg-br0文件: DEVICE=br0TYPE=BridgeBOOTPROTO=staticBROADCAST=10.1.255.255IPADDR=10.1.29.3NETMASK= ...

  8. nslookup、arp、netstat、traceroute

    nslookup 主要用于测试DNS服务器是否正常工作,除此之外,还可以对域名和IP地址进行查询. [root@weekend110 ~]# nslookup> www.guet.edu.cn ...

  9. A Tour of Go Forever

    If you omit the loop condition it loops forever, so an infinite loop is compactly(简洁地:紧密地:细密地) expre ...

  10. Selenium 进行web自动化测试

    1.安装火狐版本时注意,如果无法正常安装,应该点击右键---以管理员身份运行 2.安装成功后,选择工具--选项--高级--更新,停止其自动化更新 3.maven里面加载应有的selenium的组件