drupal-with-nginx
drupal-with-nginx copied to clipboard
Using drupal-with-nginx and running php5-fpm under different users
I manage several websites from several clients hosted on the same server. I know how to set up the php-fpm pool files to run under unique users and am defining different sockets for each pool. This part works fine.
(I'm just starting to learn NGINX, so forgive my noobness.)
The config files use "phpcgi" to hold the pool settings. These are picked up from an "upstream phpcgi" directive with the actual socket name in it that I put in the individual site's conf files. I removed the upstream directove from upstream_phpcgi_unix.conf.
But this leaves me with multiple "upstream phpcgi" declarations across all of the site's config files and NGINX's configtest now says: nginx: [emerg] duplicate upstream "phpcgi" in /etc/nginx/vhosts.d/blah.conf
Since "phpcgi" is used all over the place, how can I set the FPM socket uniquely per site using the drupal-with-nginx files?
I had the same challenge. In each site config, I added the line: set $socket /var/....;
Then I changed all occurrences of : fastcgi_pass phpcgi; to: fastcgi_pass $socket;
This is likely not the most elegant way to solve this, but it appears to work.
I did it by defining per-site 'upstream's in upstream_phpcgi_unix.conf, then referencing a them as a variable as @jkounis has done. I also set a default value somewhere. I'm using php7.0-fpm, but I don't think that detail matters.