nginx for Windows

Windows下的nginx

Known issues
已知问题
Possible future enhancements
可能的未来改进

Version of nginx for Windows uses the native Win32 API (not the Cygwin emulation layer). Only the select() and poll() (1.15.9) connection processing methods are currently used, so high performance and scalability should not be expected. Due to this and some other known issues version of nginx for Windows is considered to be a beta version. At this time, it provides almost the same functionality as a UNIX version of nginx except for XSLT filter, image filter, GeoIP module, and embedded Perl language.

Windows版nginx使用本地Win32 API(而非Cygwin模拟器)。目前只使用了select()和poll()(nginx版本1.15.9)的连接处理方法,因此不能期待高性能和可扩展性。由于上述问题和其他一些已知问题,Windows版nginx被视为测试版。目前,除XSLT过滤器、图像过滤器、GeoIP模块和嵌入式Perl语言外,它提供的功能与UNIX版nginx几乎相同。

To install nginx/Windows, download the latest mainline version distribution (1.25.2), since the mainline branch of nginx contains all known fixes. Then unpack the distribution, go to the nginx-1.25.2 directory, and run nginx. Here is an example for the drive C: root directory:

要在windows中安装nginx,请下载最新的版本(1.25.2),因为nginx的最新版本修复了所有已知问题。解压后,进入nginx-1.25.2目录,运行nginx。下面以C盘根目录为例:

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

Run the tasklist command-line utility to see nginx processes:

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

C:\nginx-1.25.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

One of the processes is the master process and another is the worker process. If nginx does not start, look for the reason in the error log file logs\error.log. If the log file has not been created, the reason for this should be reported in the Windows Event Log. If an error page is displayed instead of the expected page, also look for the reason in the logs\error.log file.

其中一个是主进程,另一个是工作进程。如果nginx没有启动,请在错误日志文件中logs\error.log查找原因。如果未创建日志文件,则应在Windows事件日志中报告原因。如果显示的是错误页面而不是预期页面,也应在日志文件logs\error.log中查找原因。

nginx/Windows uses the directory where it has been run as the prefix for relative paths in the configuration. In the example above, the prefix is C:\nginx-1.25.2\. Paths in a configuration file must be specified in UNIX-style using forward slashes:

Windows下的nginx使用运行目录作为配置中相对路径的前缀。在上面的例子中,路径是C:\nginx-1.25.2\。配置文件中的路径必须使用以UNIX的正斜杠方式指定:

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

nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands:

nginx以标准控制台应用程序(非服务)的形式运行时,可使用以下命令对其进行管理:

nginx -s stop fast shutdown 快速关闭
nginx -s quit graceful shutdown 优雅关闭
nginx -s reload changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
更新配置,开启使用新配置的新进程,优雅的关闭旧进程
nginx -s reopen re-opening log files重新打开日志文件

Known issues

已知问题

Possible future enhancements

可能的未来改进