Welcome! Log In Create A New Profile

Advanced

One unix socket for all php-fpm pools - possible?

Posted by Demontager 
One unix socket for all php-fpm pools - possible?
September 12, 2013 04:16PM
I want to set only one listening unix socket for all php-fpm pools, but fpm requires them to be deferent. Production server has 2 gb ram and i noticed that it started to be not enough, adding more websites spawn more fpm processes. Me is only one user on this server, so i don't need to limit resources per pool just want to set common config settings for all. One domain pool as follows:
[domain.com]
user = www
group = www
listen = /tmp/domain.com-php-fpm.sock
security.limit_extensions = .php .html

;Resources
pm = dynamic
pm.max_children = 9
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.process_idle_timeout = 60s
request_terminate_timeout = 30s
pm.max_requests = 300

;Log errors
catch_workers_output = yes
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/www/domain.com/php-error.log

;Base dirs
php_admin_value[open_basedir] = /usr/local/www/domain.com
php_admin_value[upload_tmp_dir] = /usr/local/www/domain.com/tmp
php_admin_value[session.save_path] = /usr/local/www/domain.com/tmp

Another pool is the name, except domain name. So then if I set same listening socket for both pools it doesn't work

# php-fpm --test
[12-Sep-2013 22:27:01] ERROR: [pool domain.com] unable to set listen address as it's already used in another pool 'domain2.com'
[12-Sep-2013 22:27:01] ERROR: failed to post process the configuration
[12-Sep-2013 22:27:01] ERROR: FPM initialization failed

And if set deferent sockets, it works, but each pool spawn minimum 3 process. (Sure, this is not an output from real server, just simulated same behavior).

# ps aux | grep php-fpm
root 1349 0.0 0.9 161376 18320 ?? Ss 10:34PM 0:00.02 php-fpm: master process (/usr/local/etc/php-fpm.conf) (php-fpm)
www 1350 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain2.com (php-fpm)
www 1351 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain2.com (php-fpm)
www 1352 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain2.com (php-fpm)
www 1353 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain.com (php-fpm)
www 1354 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain.com (php-fpm)
www 1355 0.0 0.9 161336 18292 ?? S 10:34PM 0:00.00 php-fpm: pool domain.com (php-fpm)

My intention is to keep running 3 php-fpm processes for all pools.
Re: One unix socket for all php-fpm pools - possible?
September 12, 2013 05:01PM
Just want to add. Yes, I realize it's not possible to have one socket for all pools and sure i may use one pool only. It will serve as template for all websites. But here one caveat - big security risk as i can't define per website php_admin_value[open_basedir] value which restricts moving up website directory level, so if assume one website hacked, they can't infect others.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 72
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready