Php-fpm

From wiki.techunit.org
Jump to: navigation, search

Introduction

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. You can use it with Apache and Nginx, it increase you PHP web service performance.

  • Realized on :
    • Debian 8
    • Ubuntu 14.04
  • php5-fpm versions :
    • 5.6.24
    • 5.5.9

Configuration

Install the packages

aptitude install php5-fpm -y

Configure your first host

  • Edit /etc/php5/fpm/pool.d/www/example.com.conf
[www.example.com]
user = www-example                         # User and group used by the process to access web root directory        
group = www-example
listen = /var/run/php5-fpm-www.sock        # You have to bind your webserver to this socket
listen.owner = www-data                    # User and group used by the socket
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system      # Disable some PHP functions
php_admin_flag[allow_url_fopen] = off
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
security.limit_extensions =                # You can use it to disable access to some extensions

Apply permissions to root directory

chown -R www-example: /var/www/www.example.com/

Restart service

service php5-fpm restart

Configure your web server to use php-fpm

Configure php-fpm with Nginx