nginx on Windows Vista / Windows 7 with php

You can get the latest stable version of a Windows compile of nginx (0.7.64) here.

Setup is quite straight forward; you’ll need the php-cgi.exe downloaded (copy the libmysql*.dll to the Windows system directory – quickest but dirtiest solution) and tied in; I assume that you can download and run the mysql application yourself?

You may need to run the startup as a batch file (f: below is the drive installed on, php has been extracted into the php under nginx as you can see). PHP is set to listen on port 9000, which nginx interfaces requests to below.

@ECHO OFF
cd f:\nginx
start /B cmd /K "f:\nginx\nginx.exe"
start /B cmd /K "f:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c f:\nginx\php\php.ini"
ping 127.0.0.1 -n 1>NUL
echo Starting nginx
echo .
echo .
echo .
ping 127.0.0.1 >NUL
EXIT

In a Windows Environment, you’ll want to link to the php-cgi.exe:

location ~ \.php$ {
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  f:/nginx/html/$fastcgi_script_name;
include        fastcgi_params;
}

and you may want to set some gzip compression for nginx:

 keepalive_timeout   65;

 gzip                on;
 gzip_http_version   1.1;
 gzip_vary           on;
 gzip_comp_level     6;
 gzip_buffers        16 8k;
 gzip_proxied        any;
 gzip_min_length     1000;
 gzip_types          text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;