Bitnami PHP-FPM

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.

PHP-FPM is an alternative PHP FastCGI implementation with additional features.

How to configure PHP-FPM options?

To override any of the PHP configuration options (eg. memory_limit, max_execution_time), set these options in the installdir/php/etc/php.ini file and in the installdir/apps/APPNAME/conf/php-fpm/php-settings.conf file.

For example, to increase the PHP memory limit, edit the installdir/APPNAME/conf/php-fpm/php-settings.conf file and set the corresponding variable as follows. Replace the NEW_LIMIT placeholder with the new memory limit you wish to use.


Then, also modify the installdir/php/etc/php.ini file and set the memory_limit variable to a new value, as shown below:


Restart Apache and PHP-FPM for the changes to take effect:

$ installdir/ restart apache
$ installdir/ restart php-fpm

How to configure PHP-FPM processes?

It is possible to configure PHP-FPM processes per application. If you have a lot of applications, this may result in excessive CPU usage.

  • You can configure your application's PHP-FPM processes to start automatically when needed. Add this option to the installdir/apps/APPNAME/conf/pfp-fpm/pool.conf file:

  • You can also reduce the number of PHP-FPM processes per application by modifying the files below.

    • If you configured the processes to start dynamically, modify the installdir/php/etc/common-dynamic.conf as below:

    • If you configured the processes to start on demand, modify the installdir/php/etc/common-ondemand.conf as below:


How to disable PHP-FPM?

To disable an already enabled PHP-FPM configuration, follow these steps:

  • Disable mpm_event by commenting the LoadModule directive:

     #LoadModule mpm_event_module modules/
  • Enable mpm_prefork by uncommenting its LoadModule directive:

     LoadModule mpm_prefork_module modules/
  • Enable mod_php by uncommenting its LoadModule directive:

     LoadModule php5_module  modules/
  • Restart Apache:

     $ installdir/ restart apache
  • Stop PHP-FPM:

     $ installdir/ stop php-fpm
  • Disable PHP-FPM:

     $ sudo mv installdir/php/scripts/ installdir/php/scripts/

How to enable FastCGI on Windows?

PHP-FPM is not built with the windows binaries. However, it is possible to use PHP-CGI. The executable php-cgi.exe that is bundled in our stacks is a FastCGI interface. Note that it is not FPM (Fastcgi Process Manager) and does not have multi-threading or concurrent request support, nor support for any of the FPM configuration options. Find below the steps to enable it:

  • Assuming your application is running under installdir\apps\application directory, edit installdir\php\php.ini file and set doc_root parameter as below:

    doc_root = "installdir/apps/application/htdocs/"
  • Download winserv from this link.
  • Extract winserv.exe and place it on installdir\scripts directory.
  • Execute this command to create the FastCGI service:

    installdir\scripts\winserv.exe install phpCGI -displayname phpCGI -start auto "installdir\php\php-cgi.exe" -b -c="installdir\php\php.ini"
  • Add the line below in installdir\properties.ini file, inside PHP section:

  • Execute installdir\manager-windows.exe and start PHP server on Manage Servers tab.
  • Edit installdir\apache2\conf\httpd.conf file and enable mod_proxy, mod_proxy_fcgi and authnz_fcgi modules. For that, uncomment these lines:

    #LoadModule proxy_module modules/
    #LoadModule proxy_fcgi_module modules/
    #LoadModule authnz_fcgi_module modules/
  • Add the code below in installdir\apps\application\conf\httpd-app.conf file, inside Directory tag:

    <FilesMatch "\.php$">
      <If "-f %{REQUEST_FILENAME}">
        SetHandler "proxy:fcgi://"
  • Restart Apache server.

How to enable PHP-FPM?

PHP-FPM is disabled by default. To enable it, follow these steps:

  • Enable its control script:

     $ cd installdir
     $ mv php/scripts/ php/scripts/
  • Start PHP-FPM:

     $ cd installdir
     $ ./ start php-fpm
  • Enable PHP-FPM configuration in Apache. Update the installdir/apache2/conf/httpd.conf file and comment out the LoadModule directive:

     # Comment the below module to enable PHP-FPM
     # LoadModule php5_module  modules/
     # This enables using PHP-FPM when mod_php is disabled
     <IfModule !php5_module>
         Define USE_PHP_FPM
  • In the same file, disable the mpm_prefork module:

     #LoadModule mpm_prefork_module modules/
  • In the same file, enable the mpm_event module:

     LoadModule mpm_event_module modules/
  • Restart Apache:

     $ cd installdir
     $ ./ restart apache


PHP-FPM did not handle the connection error

PHP-FPM is configured such that PHP requests are delivered to the appropriate PHP-FPM pool. It may happen, however, that none of those pools consumes the request, either because it is a custom application that was not configured to use PHP-FPM, or because of a misconfiguration.

In these cases, Apache tries to serve the plaintext version of the PHP file (its source code), which may contain sensitive information. To avoid this, we have configured the server to throw an error of the form:

Not Found
The requested URL /bitnami-error-php-fpm-did-not-handle-the-connection/info.php was not found on this server.

If you come across this error, please post a question in our community forums and we will help you troubleshooting the error and release a fixed version of the misconfigured application if needed.

NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.

Bitnami Documentation