Nginx中文文档
DocsHome
  • 贡献导引
  • 介绍
    • 安装 nginx
    • 从源码构建 nginx
    • 初学者指南
    • 管理指南
    • 控制 nginx
    • 连接处理方式
    • 设置哈希
    • 调试日志
    • 记录日志到 syslog
    • 配置文件度量单位
    • 命令行参数
    • Windows 下的 nginx
    • QUIC 和 HTTP/3 支持
    • nginx 如何处理请求
    • 服务器名称
    • 使用 nginx 作为 HTTP 负载均衡器
    • 配置 HTTPS 服务器
    • nginx 如何处理 TCP/UDP 会话
    • 关于 nginScript
  • 其他
    • Linux 软件包
  • How-To
    • 在 Win32 平台上使用 Visual C 构建 nginx
    • 设置 Amazon EC2 的 Nginx Plus 环境
    • 使用 DTrace pid 提供程序调试 nginx
    • 转换重写规则
    • WebSocket 代理
  • 开发
    • 贡献指南
    • 开发指南
  • 模块参考
  • 核心功能
    • HTTP
      • ngx_http_core_module
      • ngx_http_access_module
      • ngx_http_addition_module
      • ngx_http_api_module
      • ngx_http_auth_basic_module
      • ngx_http_auth_jwt_module
      • ngx_http_auth_request_module
      • ngx_http_autoindex_module
      • ngx_http_browser_module
      • ngx_http_charset_module
      • ngx_http_dav_module
      • ngx_http_empty_gif_module
      • ngx_http_f4f_module
      • ngx_http_fastcgi_module
      • ngx_http_flv_module
      • ngx_http_geo_module
      • ngx_http_geoip_module
      • ngx_http_grpc_module
      • ngx_http_gunzip_module
      • ngx_http_gzip_module
      • ngx_http_gzip_static_module
      • ngx_http_headers_module
      • ngx_http_hls_module
      • ngx_http_image_filter_module
      • ngx_http_index_module
      • ngx_http_js_module
      • ngx_http_keyval_module
      • ngx_http_limit_conn_module
      • ngx_http_limit_req_module
      • ngx_http_log_module
      • ngx_http_map_module
      • ngx_http_memcached_module
      • ngx_http_mirror_module
      • ngx_http_mp4_module
      • ngx_http_perl_module
      • ngx_http_proxy_module
      • ngx_http_random_index_module
      • ngx_http_realip_module
      • ngx_http_referer_module
      • ngx_http_rewrite_module
      • ngx_http_scgi_module
      • ngx_http_secure_link_module
      • ngx_http_session_log_module
      • ngx_http_slice_module
      • ngx_http_spdy_module(过时)
      • ngx_http_split_clients_module
      • ngx_http_ssi_module
      • ngx_http_ssl_module
      • ngx_http_status_module(过时)
      • ngx_http_stub_status_module
      • ngx_http_sub_module
      • ngx_http_upstream_module
      • ngx_http_upstream_conf_module
      • ngx_http_upstream_hc_module
      • ngx_http_userid_module
      • ngx_http_uwsgi_module
      • ngx_http_v2_module
      • ngx_http_xslt_module
    • Mail
      • ngx_mail_core_module
      • ngx_mail_auth_http_module
      • ngx_mail_proxy_module
      • ngx_mail_ssl_module
      • ngx_mail_imap_module
      • ngx_mail_pop3_module
      • ngx_mail_smtp_module
    • Stream
      • ngx_stream_core_module
      • ngx_stream_access_module
      • ngx_stream_geo_module
      • ngx_stream_geoip_module
      • ngx_stream_js_module
      • ngx_stream_keyval_module
      • ngx_stream_limit_conn_module
      • ngx_stream_log_module
      • ngx_stream_map_module
      • ngx_stream_proxy_module
      • ngx_stream_realip_module
      • ngx_stream_return_module
      • ngx_stream_split_clients_module
      • ngx_stream_ssl_module
      • ngx_stream_ssl_preread_module
      • ngx_stream_upstream_module
      • ngx_stream_upstream_hc_module
      • ngx_stream_zone_sync_module
    • 其他
      • ngx_google_perftools_module
由 GitBook 提供支持
在本页
  • 已知问题
  • 以后可能的发展
  • 原文档
  1. 介绍

Windows 下的 nginx

上一页命令行参数下一页QUIC 和 HTTP/3 支持

最后更新于5年前

Nginx 的 Windows 版本使用了本地的 Win32 API(而不是 Cygwin 模拟层)。目前仅使用 select() 和 poll() (1.15.9) 连接处理方式。由于此版本和其他存在已知的问题的 Nginx Windows 版本都被认为是 beta 版本,因此您不应该期望它具有高性能和可扩展性。现在,它提供了与 Unix 版本的 nginx 几乎相同的功能,除了 XSLT 过滤器、图像过滤器、GeoIP 模块和嵌入式 Perl 语言。

要安装 nginx 的 Windows 版本,请 最新的主线发行版(1.17.2),因为 nginx 的主线分支包含了所有已知的补丁。之后解压文件到 nginx-1.17.2 目录下,然后运行 nginx。以下是 C盘 的根目录:

cd c:\
unzip nginx-1.17.2.zip
cd nginx-1.17.2
start nginx

运行 tasklist 命令行工具查看 nginx 进程:

C:\nginx-1.17.2>tasklist /fi "imagename eq nginx.exe"

Image Name           PID Session Name     Session#    Mem Usage
=============== ======== ============== ========== ============
nginx.exe            652 Console                 0      2 780 K
nginx.exe           1332 Console                 0      3 112 K

其中有一个是主进程(master),另一个是工作进程(worker)。如果 nginx 未能启动,请在错误日志 logs\error.log 中查找原因。如果日志文件尚未创建,可以在 Windows 事件日志中查找原因。如果显示的页面为错误页面,而不是预期结果,也可以在 logs\error.log 中查找原因。

Nginx 的 Windows 版本使用运行目录作为配置文件中的相对路径前缀。在上面的例子中,前缀是 C:\nginx-1.17.2\。在配置文件中的路径必须使类 Unix 风格的正斜杠:

access_log   logs/site.log;
root         C:/web/html;

Nginx 的 Windows 版本作为标准的控制台应用程序(而不是服务)运行,可以使用以下命令进行管理:

  • nginx -s stop 快速退出

  • nginx -s quit 正常退出

  • nginx -s reload 重新加载配置文件,使用新的配置启动工作进程,正常关闭旧的工作进程

  • nginx -s reopen 重新打开日志文件

已知问题

  • 虽然可以启动多个工作进程,但实际上只有一个工作进程做完全部的工作

  • 不支持 UDP 代理功能

以后可能的发展

  • 作为服务运行

  • 使用 I/O 完成端口作为连接处理方式

  • 在单个工作进程中使用多个工作线程

原文档

http://nginx.org/en/docs/windows.html
下载
已知问题
以后可能的发展