How do I change the NGINX user?
Solution 1:
Run nginx & php-fpm as www:www
1. Nginx
Edit nginx.conf and set user to www www;
If the master process is run as root, then nginx will setuid()/setgid() to USER/GROUP. If GROUP is not specified, then nginx uses the same name as USER. By default it's nobody user and nobody or nogroup group or the --user=USER and --group=GROUP from the ./configure script.
2. PHP-FPM
Edit php-fpm.conf and set user and group to www
.
user - Unix user of processes. Default "www-data"
group - Unix group of processes. Default "www-data"
Solution 2:
In Ubuntu 14.04 the file to change user and group in PHP-FPM is: /etc/php5/fpm/pool.d/www.conf
. In this file change these parameters:
user = www
group = www
listen.owner = www
listen.group = www
Solution 3:
To answer your actual question is to just change the user
line in nginx.conf
like so:
user [username];
Example:
user www-data;
The preferred user for Nginx to run as actually differs between operating systems. Sometimes Nginx is supposed to run as www-data
. Other times it is actually supposed to run as nobody
.
On some operating systems (such as Windows), it doesn't even matter, and the user
line in nginx.conf
can be commented out or entirely excluded.