Home » Php » fastcgi – php-fpm for Windows?

fastcgi – php-fpm for Windows?

Posted by: admin April 23, 2020 Leave a comment


The PHP-FPM’s homepage http://php-fpm.org/ states that it is part of PHP since PHP 5.3.3. Now, I was wondering, when I download the newest PHP binaries from php.net, there is no php-fpm in it. How do I get it? Is it even available for Windows?

How to&Answers:

Here how to setup php-fpm on Windows:

  1. Download the .zip file from http://windows.php.net/download/. The .zip file should be VC9 which has the FastCGI file (php-cgi.exe). Don’t download VC6, and don’t download the .msi file because it requires that you have IIS setup already in order to install php-fpm. The zip file contains the php-cgi.exe which is what you need for php-fpm. I downloaded a slightly older version, php-5.3.10-Win32-VC9-x86.zip, from here http://windows.php.net/downloads/releases/archives/ because I wanted to match the version running on my production server.

  2. Unzip the file, e.g. unzip into C:\php-5.3.10-Win32-VC9-x86

  3. Edit the php.ini file as needed. What I did:

    # nginx security setting
    extension_dir = "C:\php-5.3.10-Win32-VC9-x86\ext"

    enable the following modules by uncommenting them:

  4. Create a .bat file somewhere, e.g. start-php-fcgi.bat in webserver directory or in the PHP directory:

    ECHO Starting PHP FastCGI...
    set PATH=C:\php-5.3.10-Win32-VC9-x86;%PATH%
    C:\php-5.3.10-Win32-VC9-x86\php-cgi.exe -b -c C:\php-5.3.10-Win32-VC9-x86\php.ini
  5. Double click the .bat file to start php-fpm. A window will popup and stay open while its running. Its kind of annoying, but just haven’t looked into setting it up as service yet.

  6. Configure your webserver. If you wish to use it with nginx, here a config sample for

    location ~ \.php$ {
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include         fastcgi_params;


Alan’s answer is a great start. However, for Apache 2.4 and later you do not need to run PHP-FPM as a separate service, you can use mod_fcgid to handle everything within Apache.

Here is an example configuration:

LoadModule fcgid_module modules/mod_fcgid.so

FcgidInitialEnv PHPRC "c:/php"
FcgidInitialEnv PATH "c:/php;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;"
FcgidInitialEnv SystemRoot "C:/Windows"
FcgidInitialEnv SystemDrive "C:"
FcgidInitialEnv TEMP "C:/WINDOWS/Temp"
FcgidInitialEnv TMP "C:/WINDOWS/Temp"
FcgidInitialEnv windir "C:/WINDOWS"
FcgidIOTimeout 64
FcgidConnectTimeout 16
FcgidMaxRequestsPerProcess 500

<Files ~ "\.php$">
  AddHandler fcgid-script .php
  FcgidWrapper c:/php/php-cgi.exe .php

Note, this is based on a post in Apache Lounge. As helpful as it was, their version had quotes around c:/php/php-cgi.exe and if you do that it WILL NOT START php-cgi.exe, at least on Windows Server 2012, and you get HTTP 500. Took me a painful few days to figure that out.


Old as this post is I have to weigh in here because what has been posted here is not PHP-FPM, it’s running PHP using Fast-CGI.

Yes PHP-FPM stands for PHP-FastCGI Process Manager and so implements FastCGI but you are forgetting that FPM is much more than that as it contains process management features that are not managed by the webserver.

On *nix systems PHP-FPM has a separate process that manages the PHP child processes and has a detailed configuration to specify how these processes are managed. For details on these features read here

Launching a CGI process on windows is not the same thing. It does not spaw worker processes or dynamically scale them or allow multi-threading.

There is no PHP-FPM for windows yet.

However as suggested, you may launch a CGI process if you wish.


Starting PHP v5.3.3, FPM Server-API [SAPI] support has been integrated into core PHP. This means, you can take PHP’s source codes and compile and build them with FPM-SAPI [using --enable-fpm configuration parameter] support, instead of let’s say Apache SAPI [--enable-apx2]. As shown in PHP-Wiki you can build PHP almost the same way you do in *nix systems – that is, configuration-wise. I would suggest you learn the ins and outs of building PHP in *nix systems first, and even try to do it yourself [usual configure, make and make install pattern], and then try to utilize the experience gained from it to build on Windows environment.

In addition to --enable-fpm configuration parameter, there are two additional parameters as well: --with-fpm-user=USERNAME_HERE and --with-fpm-group=USERGROUPNAME_HERE. These two work in *nix environment, but may not be available in Windows.

Overall, I am pretty sure you can build your own PHP-FPM server app on Windows using Visual Studio IDE. There are no official PHP-FPM builds as of the date of this writing.

EDIT 1: Ok, guess I might be wrong re the possibility of building PHP-FPM on Windows, since this SAPI uses libevent component from *nix environment. Guess you will have to stick with Cygwin-bundled installation after all.


PHP-FPM is only available to linux as of now. There are some sites that provides a tutorial on how to get php-fpm to run on windows, under cygwin. You can try those guides.