PHP-FPM

    How to enable PHP-FPM

     

    PHP-FPM is enabled by default in virtual machines and Ubuntu-based cloud images.

    For native installers deployments and Bitnami Cloud Hosting Ubuntu servers you can enable it following some basic steps:

     

    1) Enable its ctl.sh script:

    mac_platform.png

    On OS X:

    host:~ user$ cd /Applications/application-version
     host:~ user$ mv php/scripts/ctl.sh.disabled php/scripts/ctl.sh
    

    linux_platform.pngOn Linux (native installers):

    $ cd ~/application-version
     $ mv php/scripts/ctl.sh.disabled php/scripts/ctl.sh
    
     
    linux_platform.pngOn Linux (virtual machines, cloud images and Bitnami Cloud Hosting):
    $ cd /opt/bitnami
     $ sudo mv php/scripts/ctl.sh.disabled php/scripts/ctl.sh
    
     

    2) Start PHP-FPM:

    mac_platform.png

    On OS X:

    host:~ user$ cd /Applications/application-version
     host:~ user$ ./ctlscript.sh start php-fpm 
    

    linux_platform.pngOn Linux (native installers):

    $ cd ~/application-version
     $ ./ctlscript.sh start php-fpm
    

    linux_platform.pngOn Linux (virtual machines, cloud images and Bitnami Cloud Hosting):

    $ cd /opt/bitnami
     $ sudo ./ctlscript.sh start php-fpm
    
     

    3) Enable PHP-FPM configuration in Apache. To do this, you will simply need to disable mod_php, and after restarting Apache, it will switch to the PHP-FPM mode. You just need to open apache2/conf/httpd.conf and look for the below section: 

     
    # Comment the below module to enable PHP-FPM
    LoadModule php5_module        modules/libphp5.so
    # This enables using PHP-FPM when mod_php is disabled
    <IfModule !php5_module>
        Define USE_PHP_FPM
    </IfModule>
     

    And comment the php5_module line:

    # Comment the below module to enable PHP-FPM
    # LoadModule php5_module        modules/libphp5.so
    # This enables using PHP-FPM when mod_php is disabled
    <IfModule !php5_module>
        Define USE_PHP_FPM
    </IfModule>

     

    In addition, as mod_php is being disabled, you can now enable the Event MPM in Apache, which greatly improves its performance. Just look for the line:

    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

    Comment it:

    #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    

     

    And then enable mpm_event_module lookin for the line:

    #LoadModule mpm_event_module modules/mod_mpm_event.so

    And uncomment it:

    LoadModule mpm_event_module modules/mod_mpm_event.so

    NOTE: If you cannot find the commented out line (#LoadModule mpm_event_module modules/mod_mpm_event.so) simply add the uncommented version below the #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so  you just commented.

     

    4) Restart Apache: 

    mac_platform.png

     

    On OS X:
     host:~ user$ cd /Applications/application-version
     host:~ user$ ./ctlscript.sh restart apache 
    

    linux_platform.pngOn Linux (native installers):

    $ cd ~/application-version
     $ ./ctlscript.sh restart apache
    

    linux_platform.pngOn Linux (virtual machines, cloud images and Bitnami Cloud Hosting):

    $ cd /opt/bitnami
     $ sudo ./ctlscript.sh restart apache
    

    PHP-FPM is now enabled!

    How to disable PHP-FPM

     

    If you want to disable an already enabled PHP-FPM configuration, you will just need to revert the above mentioned steps:

     

    1) Disable mpm_event by commenting the LoadModule:
     
    From:
    LoadModule mpm_event_module modules/mod_mpm_event.so

    To:

    #LoadModule mpm_event_module modules/mod_mpm_event.so
    

     

    2) Enable mpm_prefork by uncommenting its LoadModule:
     
    From:
    #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

    To:

    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
     
    3) Enable mod_php by uncommenting its LoadModule:
     
    From:
     
    # LoadModule php5_module        modules/libphp5.so
    
     
    To:
    LoadModule php5_module        modules/libphp5.so
    
     
     
    4) Restart apache:
     
     /opt/bitnami/ctlscript.sh restart apache
     
     
    5) Stop PHP-FPM:
     
     /opt/bitnami/ctlscript.sh stop php-fpm
     
    6) Disable PHP-FPM
     
     sudo mv /opt/bitnami/php/scripts/ctl.sh /opt/bitnami/php/scripts/ctl.sh.disabled
     

    How to start/stop PHP-FPM server?

    The Stacks include a graphical tool to manage the servers easily. You can find the"manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory:

     

    mac_platform.png

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start php-fpm
    

    linux_platform.pngOn Linux:

    $ cd ~/application-version
    $ ./ctlscript.sh start php-fpm

    PHP-FPM did not handle the connection error

    PHP-FPM is configured in a way 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 on our side. 

    In those cases, Apache would try to serve the plain text version of the PHP file (its source code), which may contain sensible information. To avoid it, we 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.

     

    Where the trailing "info.php" may change depending on the file that caused the error when serving it.

    If you find 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.

    PHP Options on htaccess.conv with PHP-FPM

    As we are using PHP-FPM, if you want to override any of the PHP configuration (i.e: php_value memory_limit, php_value max_execution_time...) it won't work if you write it on the htaccess.conf file, you must write this options on:

    /opt/bitnami/php/etc/php.ini
     
    Once you have finished, you must restart apache and PHP-FPM.
    /opt/bitnami/ctlscript.sh restart apache
    /opt/bitnami/ctlscript.sh restart php-fpm
    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    13546 view(s), 18 edit(s) and 9494 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments