Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the user that nginx worker processes run under (Ubuntu 12.04)

Tags:

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.

like image 813
iamyojimbo Avatar asked Aug 01 '13 20:08

iamyojimbo


People also ask

How do I run nginx from another user?

Run as an unprivileged user First, create a new user without sudo privileges. Then you can configure nginx to run as an unprivileged system user (e.g., not the root user or a user with sudo privileges). This is done via the user directive in the /etc/nginx/nginx. conf configuration file.

Which user is the owner of the nginx process?

One process is owned by root , the other one is owned by www-data . I didn't changed the nginx. conf yet, so the configured user is still www-data .

What is default nginx user?

By default nginx uses www-data user for purpose of website and application, it is also the same user name that was used by the server of apache. Sometimes we need to change the user in our website for security reasons or we can also change the user for another purpose.

What is worker processes nginx?

What are worker_processes in Nginx. The worker_processes are used to specify the total number of worker processes to spawn simultaneously. The number of worker_processes in Nginx is set to one by default. Executing one worker process per CPU core works perfectly, and we also recommend you configure it in this way.


1 Answers

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.

like image 114
deagh Avatar answered Oct 04 '22 20:10

deagh