Nginx 是一个轻量级的高性能 Http WebServer,以事件驱动方式编写,因此相比 Apache 而言,Nginx 更加稳定、性能更好,而且配置简单,资源占用较低。

1. 安装 Nginx

从 v0.7.52 开始,Nginx 开始发布 Windows 版本的 Nginx,你可以在其官方网站上面下载:http://nginx.net

下载后直接解压即可,这里解压缩到c:\nginx目录。

2. 启动Nginx

命令行进入c:\nginx目录,运行nginx.exe,启动控制台窗口。默认启用80端口。用过Tomcat的人都希望能在控制台看到启动日志,nginx的日志却不得不查看logs目录下的相应log文件。

3. 访问欢迎html页

在浏览器中访问http://localhost,可以看到默认的欢迎页.

4. 停止Nginx

Ctrl+C没反应。于是关闭控制台窗口。可是再访问http://localhost依然有效。查看进程,发现nginx根本没有被关闭。因此如果想彻底关闭nginx,应该是

  1. nginx -s stop

请参考官方文档nginx/Windows usage

或者使用windows的taskkill命令:

  1. taskkill /F /IM nginx.exe > nul

5. Ngnix常用配置

Nginx的所有配置都默认使用conf/nginx.conf文件,其地位相当于apache的httpd.conf文件
。当运行nginx.exe暗含运行了nginx -c conf\nginx.conf.
如果想使用自己定义的conf文件如my.conf,命令为nginx -c conf\my.conf.

常用配置如下:

  1. http {
  2. server {
  3. #1.侦听80端口
  4. listen  80;
  5. location / {
  6. # 2. 默认主页目录在nginx安装目录的html子目录。
  7. root   html;
  8. index  index.html index.htm;
  9. # 3. 没有索引页时,罗列文件和子目录
  10. autoindex on;
  11. autoindex_exact_size on;
  12. autoindex_localtime on;
  13. }
  14. # 4.指定虚拟目录
  15. location /tshirt {
  16. alias D:\programs\Apache2\htdocs\tshirt;
  17. index index.html index.htm;
  18. }
  19. }
  20. # 5.虚拟主机www.emb.info配置
  21. server {
  22. listen          80;
  23. server_name     www.emb.info;
  24. access_log emb.info/logs/access.log;
  25. location / {
  26. index index.html;
  27. root  emb.info/htdocs;
  28. }
  29. }
  30. }

小提示:

运行nginx -V可以查看该Win32平台编译版支持哪些模块。我这里的结果为:

  1. nginx version: nginx/0.7.65
  2. TLS SNI support enabled
  3. configure arguments:
  4. --builddir=objs.msvc8
  5. --crossbuild=win32
  6. --with-debug --prefix=
  7. --conf-path=conf/nginx.conf
  8. --pid-path=logs/nginx.pid
  9. --http-log-path=logs/access.log
  10. --error-log-path=logs/error.log
  11. --sbin-path=nginx.exe
  12. --http-client-body-temp-path=temp/client_body_temp
  13. --http-proxy-temp-path=temp/proxy_temp
  14. --http-fastcgi-temp-path=temp/fastcgi_temp
  15. --with-cc-opt=-DFD_SETSIZE=1024
  16. --with-pcre=objs.msvc8/lib/pcre-7.9
  17. --with-openssl=objs.msvc8/lib/openssl-0.9.8k
  18. --with-openssl-opt=enable-tlsext
  19. --with-zlib=objs.msvc8/lib/zlib-1.2.3
  20. --with-select_module
  21. --with-http_ssl_module
  22. --with-http_realip_module
  23. --with-http_addition_module
  24. --with-http_sub_module
  25. --with-http_dav_module
  26. --with-http_stub_status_module
  27. --with-http_flv_module
  28. --with-http_gzip_static_module
  29. --with-http_random_index_module
  30. --with-http_secure_link_module
  31. --with-mail
  32. --with-mail_ssl_module
  33. --with-ipv6

显然,最经常用的memcache, rewrite模块都没在其中,因此该win32编译版本仅能供基本开发测试使用,对于产品平台,应该重新编译自己想要的win32版本,或者在linux下使用更方便。

Nginx - Windows下Nginx基本安装和配置的更多相关文章

  1. windows下Anaconda的安装与配置正解

    一.下载anaconda 第一步当然是下载anaconda了,官方网站的下载需要用迅雷才能快点,或者直接到清华大学镜像站下载. 清华大学提供了镜像,从这个镜像下载速度很快,地址: https://mi ...

  2. Nginx - Windows下Nginx初入门,附CentOS下Nginx的安装

    公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...

  3. Nginx - Windows下Nginx初入门

    公司刚使用nginx,预先学习下.鉴于机器没有Linux环境,在Windows熟悉下. 下载 目前(2015-07-11),nginx的稳定版本是1.8.0,在官网下载先,windows版的nginx ...

  4. Windows下的maven安装及配置

    有时候开发需要用到maven来进行项目管理,说下怎么配置maven吧 环境&工具: windows系统 jdk1.8 apache-maven-3.2.5.zip eclipse 首先需要去A ...

  5. windows下mysql5.7安装及配置

    装完msi后,复制my-default.ini文件,黏贴为my.ini文件,内容修改如下: # For advice on how to change settings please see# htt ...

  6. windows下Maven的安装与配置

    1 安装maven前首先确认计算机已正确安装JDK2 下载maven 地址:http://maven.apache.org/download.html安装文件格式如下:apache-maven-3.0 ...

  7. Windows下MySQL下载安装、配置与使用

    用过MySQL之后,不论容量的话,发现比其他两个(sql server .oracle)好用的多,一下子就喜欢上了.下面给那些还不知道怎么弄的童鞋们写下具体的方法步骤. (我这个写得有点太详细了,甚至 ...

  8. Windows下Git的安装及配置

    Git的BASH Git的为Windows提供了用于命令行运行的一个仿真BASH的Git.习惯LINUX和UNIX环境的你,可以在该BASH环境中输入“git”命令来完成各种版本控制的操作. 简介 G ...

  9. windows下Emacs的安装与配置

    1.下载 到这个网址可以下载到Emacs的windows版本:http://ftp.gnu.org/pub/gnu/emacs/windows/ 只需要一个压缩文档,如emacs-23.2-bin-i ...

随机推荐

  1. MongoDB使用SSL

    1. MongoDB对SSL的支持情况 MongoDB社区版本不支持SSL,企业版提供对SSL的支持.MongoDB源代码中包含SSL的实现,可以自己编译带SSL的MongoDB. MongoDB支持 ...

  2. Linux下Websphere无法关闭

    Websphere 启动关闭命令  linux 下首先查看进程 ./stopServcer.sh server1如果停不掉websphere服务.则强制杀掉其进程! 1.查看websphere进程号b ...

  3. Spring中 @Autowired注解与@Resource注解的区别

    Spring中 @Autowired注解与@Resource注解的区别在Spring 3.X中经常使用到@Autowired和@Resource进行装配.这两个注解的差异在何处???相同点:@Reso ...

  4. Java:抽象类abstract和接口Interface

    一.抽象类:abstract 抽象类就是为了继承而存在的,如果你定义了一个抽象类,却不去继承它,那么等于白白创建了这个抽象类,因为你不能用它来做任何事情.对于一个父类,如果它的某个方法在父类中实现出来 ...

  5. Eclipse无法通过FileExplore打开真机data目录

    ok ——> Eclipse无法通过FileExplore打开真机data目录 ref:http://blog.csdn.net/koyoter/article/details/7657440 ...

  6. jquery Deferred demo

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 自适应高度的 textarea

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  8. python 内建函数 type() 和 isinstance() 介绍

    Python 不支持方法或函数重载, 因此你必须自己保证调用的就是你想要的函数或对象.一个名字里究竟保存的是什么?相当多,尤其是这是一个类型的名字时.确认接收到的类型对象的身份有很多时候都是很有用的. ...

  9. [HDOJ5583]Kingdom of Black and White(暴力)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5583 一个01串,求修改一个位置,使得所有数均为0或1的子串长度的平方和最大.先分块,然后统计好原来的 ...

  10. QQ发送邮件

    //下面开始写SendEmail函数 public void SendEmail(string Emailshoujian, string Emailbiaoti, string Emailzheng ...