• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Solved PHP-FPM pool question

fred974

Daemon

Thanks: 34
Messages: 1,451

#1
Hi all,

What this the difference in having php-fpm pool written in in the following 2 ways?
Methode 1:
Code:
[username]
user = $pool
group = $pool
listen = /var/run/$pool.sock
listen.owner = www
listen.group = www
listen.mode = 0660

pm = ondemand
pm.max_children = 20
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 60s;
pm.max_requests = 200
pm.status_path = /status
request_terminate_timeout = 0

env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /home/$pool/tmp
env[TMPDIR] = /home/$pool/tmp
env[TEMP] = /home/$pool/tmp

php_admin_value[open_basedir]       = /home/$pool/public_html:/home/$pool/tmp:/usr/local/share/pear:/usr/local/lib/php
php_admin_value[disable_functions]  = "exec,passthru,shell_exec,system,proc_open,popen,show_source"
php_admin_flag[allow_url_fopen]     = on
;security.limit_extensions          = .php .shtml
php_admin_value[date.timezone]      = Europe/London

php_flag[display_errors]            = off
php_admin_flag[log_errors]          = on
php_admin_value[error_reporting]    = 30711
php_admin_value[error_log]          = /home/$pool/public_html/logs/php_error.$pool.log
php_admin_value[memory_limit]       = 128M
php_value[upload_max_filesize]      = 8M
php_value[max_execution_time]       = 60
php_admin_value[upload_tmp_dir]     = /home/$pool/tmp
php_admin_value[session.save_path]  = /home/$pool/tmp
php_admin_flag[opcache.enable]      = off

chdir = /
Methode 2:
Code:
[username]
user = $pool
group = $pool
listen = /var/run/$pool.sock
listen.owner = www
listen.group = www
listen.mode = 0660

pm = ondemand
pm.max_children = 20
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 60s;
pm.max_requests = 200
pm.status_path = /status
request_terminate_timeout = 0

env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /home/$pool/tmp
env[TMPDIR] = /home/$pool/tmp
env[TEMP] = /home/$pool/tmp

open_basedir       = /home/$pool/public_html:/home/$pool/tmp:/usr/local/share/pear:/usr/local/lib/php
disable_functions  = "exec,passthru,shell_exec,system,proc_open,popen,show_source"
php_admin_flag[allow_url_fopen     = on
;security.limit_extensions          = .php .shtml
date.timezone      = Europe/London

display_errors            = off
log_errors          = on
error_reporting    = 30711
error_log          = /home/$pool/public_html/logs/php_error.$pool.log
memory_limit       = 128M
php_value[upload_max_filesize      = 8M
php_value[max_execution_time       = 60
upload_tmp_dir     = /home/$pool/tmp
session.save_path  = /home/$pool/tmp
php_admin_flag[opcache.enable      = off

chdir = /
When or why would you use
Code:
php_admin_value[]
php_value[]
php_flag[]
Thank you
 

usdmatt

Daemon

Thanks: 440
Messages: 1,252

#3
What are you actually asking about? I'd rather not read two entire config files and try and spot the differences.

Is it just that the final "]" is missing in some of the options in the second one? If so, and the second format is working, then I would say there's no difference. I suspect the parser spots the first "[", which separates the config file setting ("php_flag"), and the name of the flag you are trying to set. The closing "]" is probably just stripped and ignored.

Of course it looks a bit wrong to omit the closing bracket and I would probably always include it just to be "correct", even if it's not needed. Also the documentation (http://php.net/manual/en/install.fpm.configuration.php) shows both brackets, with no mention of the ending one being optional; So there's always the possibility of them updating or replacing the parser at some point in a way that breaks your config.
 

fred974

Daemon

Thanks: 34
Messages: 1,451

#4
Sorry for the typo about the closing "]" .both method above work fine when used but i noticed that you can write the file in two different way so I was wondering in which case you'll use one over the other
 

abishai

Aspiring Daemon

Thanks: 126
Messages: 540

#5
1. php_admin_value is immutable in runtime
2. php_value can be changed from user script
3. php_flag is syntactic sugar for boolean values.
 

fred974

Daemon

Thanks: 34
Messages: 1,451

#6
So If I have the following in /usr/local/etc/php-fpm.d/mydomain.com.conf
Code:
php_admin_value[memory_limit]       = 128M
Am I correct to understand that trying to change the php memory_limit with the following, it won't work
Code:
define('WP_MEMORY_LIMIT', '256M');
Is that correct?
If yes, is it correct to assume that php_admin_value add a layer of security?
 

abishai

Aspiring Daemon

Thanks: 126
Messages: 540

#7
I don't know what WP_MEMORY_LIMIT does, but if it calls ini_set() or similar technics to change memory limit in runtime, then yes, it won't work.
Yes, php_admin_* adds layer of security.
 
Top