Page 1 of 1

PHP-FPM - vesta creates different backend ports for different sites?

Posted: Wed Mar 23, 2016 7:13 pm
by flasher4401
Hi!

First of all some infos about my system:
Debian 8, VestaCP (Nginx + PHP-FPM, no Apache)

I thought about adding multi-php support (php7 for some of my sites) with the help of templates. The idea was to simply set different ports for different version (e.g. php5 - 9000, php7 - 9001). I'm sure that would work just fine but that's not what i'm asking for.


I discovered that vesta uses php-fpm "backend" templates

Code: Select all

found at: /usr/local/vesta/data/templates/web/php5-fpm
and inside the default.tpl you find the directive:

Code: Select all

listen = 127.0.0.1:%backend_port%
So i wanted to search for the setting "backend_port". I assumed it would be somewhere inside the vesta folder, set to the standard port 9000. I wasn't able to find it in a config file, but i could find it in a piece of source code. %backend_port% gets "calculated" everytime it is needed by the count of the config files inside the $pool folder. So i went on the search for the $pool folder...

Code: Select all

found at:  /etc/php5/fpm/pool.d
Inside the pool.d folder are config files for all of my sites. Each config file was created by filling the template, so each file has a listen directive like

Code: Select all

listen = 127.0.0.1:port
Each site has a different port starting at 9000, going up (e.g. 9001, 9002, 9003, ...).
Why can't they all just use the same port?

I consider changing the template from

Code: Select all

listen = 127.0.0.1:%backend_port%
to

Code: Select all

listen = 127.0.0.1:9000
-flasher

Re: PHP-FPM - vesta creates different backend ports for different sites?

Posted: Wed Mar 23, 2016 7:25 pm
by skamasle
VestaCP use sockets or ports, but use a diferent port for every site,

site1.com port 9001
site2.com port 9002

If you what it owrking you need to run php5.5 on port 9000, php 7 onport 7000, edit template, edit some functions onvesta core and then it may work, so php 5, asign 900x and php 7 1000x or something like that.

So for take ports vesta scan pool.d directory and check if port is inuse or not, is not used then asign to site.

Im working on php selector forn nginx also :)

Re: PHP-FPM - vesta creates different backend ports for different sites?

Posted: Wed Mar 23, 2016 7:29 pm
by flasher4401
Yeah, but why does it use different ports? Can't it just use the same port for each site? PHP-FPM listens on port 9000, why does it have to listen also on port 9001, 9002, ..., i mean its the same program behind these ports?

Re: PHP-FPM - vesta creates different backend ports for different sites?

Posted: Wed Mar 23, 2016 8:19 pm
by skamasle
You need connect to direrent ports for better compatibility so, each user can run php-fpm instance, if not all users run on same instance and is a security problem and www-data own all files.