PHP-FPM

From Q
Jump to navigation Jump to search

Installation

File: /etc/portage/package.use
app-eselect/eselect-php fpm
dev-lang/php fpm
File: /etc/portage/make.conf
APACHE2_MODULES="[...] proxy proxy_fcgi"
File: /etc/conf.d/apache2
APACHE2_OPTS="[...] -D PROXY -D FCGID"

Configuration

# useradd --system --shell /bin/false --no-create-home --home /var/www/example.com -g apache www-example
File: /etc/php/fpm-php7.1/fpm.d/example.com.conf
[example.com]

prefix = /var/www/$pool

user = www-example
group = apache

listen = /run/php-fpm-example.com.sock

listen.owner = www-example
listen.group = apache
listen.mode = 0660

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

php_admin_value[date.timezone] = Europe/Berlin
php_admin_value[open_basedir] = /var/www/example.com:/usr/bin:/usr/share/php
php_admin_value[post_max_size] = 30M
php_admin_value[session.save_path] = /var/www/example.com/sessions
php_admin_value[sys_temp_dir] = /var/www/example.com/tmp
php_admin_value[upload_max_filesize] = 30M
php_admin_value[upload_tmp_dir] = /var/www/example.com/tmp
# rc-update add php-fpm default
# /etc/init.d/php-fpm start

PHP Error Debugging

File: /etc/php/fpm-php7.1/fpm.d/example.com.conf
[...]
catch_workers_output = yes
php_admin_flag[display_errors] = on
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /var/log/fpm-php.example.com.log
# touch /var/log/fpm-php.example.com.log
# chown www-example:apache /var/log/fpm-php.example.com.log

Chroot

File: /etc/php/fpm-php7.1/fpm.d/example.com.conf
[...]
;chroot = $prefix
;chdir = /
;php_admin_value[session.save_path] = /sessions