Welcome! Log In Create A New Profile

Advanced

Configuring PHP-FPM to run on another machine than nginx

Posted by amodpandey 
Configuring PHP-FPM to run on another machine than nginx
May 28, 2012 10:23PM
Hello,

With the current configuration we have php-fpm running on the same machine as nginx. We want to move php-fpm to run on separate machines for scaling purpose.

location ~*\.php {
root /home/ec2-user/www/api/;
include /home/ec2-user/conf/proxy.conf;
include /home/ec2-user/conf/fastcgi.conf;

if (-f $request_filename) {
fastcgi_pass 127.0.0.1:9000;
}
}

Updating fastcgi_pass to new host is not working.

Q1 Is the root config required?

Q2 How/Where does the fpm look for requested files?

Q3 I understand all fcgi parameters are passed as is.

Please suggest the nginx configuration that would work and php-fpm configuration if any.

Should we know/consider something from performance/security point of view before we move to this set up.

Thank you in advance.

Regards
Amod

Regards
Amod
Re: Configuring PHP-FPM to run on another machine than nginx
May 29, 2012 05:42AM
This works

location ~*\.php$ {
root /home/ec2-user/www/api;
include /home/ec2-user/conf/proxy.conf;
include /home/ec2-user/conf/fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#if (-f $request_filename) {
fastcgi_pass api.example.com:9000;
#}
}

}

So root is only required for fastcgi_param script filename construction. It means there is no way to mark something as root directory in the php-fpm (relative to which it should pick the php files)!!

Also I should remove if (-f $request_filename) as the file is no longer on the nginx machine. Is there a workaround to that. I assume it is better to have it for security reasons.

Thanks
Amod

Regards
Amod
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready