Page Discussion History


Revision as of 15:27, 6 January 2014 by Ray67 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


php-fcgi on Windows


nginx can interface with PHP on Windows via a FastCGI daemon, which ships with PHP: php-cgi.exe. You need to run php-cgi.exe -b<port> and use fastcgi_pass<port>; in the nginx configuration file. After being launched, php-cgi.exe will keep listening for connections in a command prompt window. To hide that window, use the tiny utility RunHiddenConsole (the original can be found at http://www.msfn.org/board/index.php?act=ST&f=70&t=49184 but downloading requires signing up for the message board. However, the binaries are identical - md5sum abc6379205de2618851c4fcbf72112eb).


  • Install nginx for win32
  • Install the Windows binaries of PHP, making sure that php-cgi.exe is installed in the same directory as php.exe.
  • Create somewhere (e.g. in c:\nginx\ a batch file start-php-fcgi.bat similar to this one:
ECHO Starting PHP FastCGI...
c:\bin\RunHiddenConsole.exe C:\PHP\php-cgi.exe -b
root c:/www;
location ~ \.php$ {
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  include        fastcgi_params;

Autostarting PHP and nginx

  • Schedule a basic (on Windows Vista) task to run the batch file above at system start up under the SYSTEM account.
  • If using Windows nginx from http://www.kevinworthington.com/nginx-for-windows, schedule a basic (on Windows Vista) task to run C:\nginx\conf\start-nginx.bat file at system start up under the SYSTEM account in starting directory C:\nginx.
  • A home made Cygwin build of Nginx can be scheduled using a batch file similar to this:
cd /d C:\cygwin\bin && bash -c /usr/local/nginx/sbin/nginx