I recently installed php-fpm on my server (CENTOS 6.5 x86_64 standard, WHM 11.44.1 (build 7)) following the instructions here: http://infoliser.com/how-to-configure-apache-2-2-with-php-fpm-using-whm-cpanel-and-easyapache/
The server API, as revealed by phpinfo()
, is now FPM/FastCGI.
However, when I run a php script containing exec('id')
, I get:
uid=99(nobody) gid=99(nobody) groups=99(nobody)
I got the impression that php-fpm would run as the uid of the owner of the php script, rather than as the owner of the http process (as in this case). This page http://php-fpm.org/ says fpm has the "Ability to start workers with different uid/gid/chroot/environment and different php.ini (replaces safe_mode)".
What am I doing wrong?
Best Answer
PHP-FPM does not execute the script as the owner of the script, but as the user configured in the matching pool config.
On my Debian system, the default pool
www
is defined in/etc/php5/fpm/pool.d/www.conf
and contains:Yours will probably have
user=nobody
andgroup=nobody
. You can create more pools and use them by assigning them in your Apache/NGINX/whatever configs.