Changing the user that nginx worker processes run

2019-04-03 06:39发布

I have a manual install of nginx on Ubuntu 12.04. When I ran ./configure I used the following options:

./configure --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_module

Now the nginx worker processes run under the www-data user in the www-data group. However, I wish to change this to a different user (called nginx in my case).

Is this possible to do after running make and make install already?

Any help would be much appreciated.

2条回答
唯我独甜
2楼-- · 2019-04-03 07:08

If you use PHP5-FPM and get a 502 error after restart nginx, take a look on /var/run/php5-fpm.sock (Debian) :

root@ns353941:/var/run# chown nginx:www php5-fpm.sock

In my case :

nginx = new nginx user

www = group for web

nginx user belong to www, obviously.

查看更多
劳资没心,怎么记你
3楼-- · 2019-04-03 07:10

As long as your new user (nginx in your case) has the proper rights, everything should work.

You have to change your user setting in nginx.conf

...
user nginx;
...

and restart/reload your server. Link to docs.

查看更多
登录 后发表回答