I wonder whether it is possible to force nginx to use some user/group for each given domain? It seems that nginx is able to run only as one given user for all the domains – in Apache I run each domain as a different user.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For static files, you don’t need to do anything about user rights. The nginx user will serve these. The same applies to Apache btw, it runs normally as User “apache” in Group “apache”.
it is in PHP that you need to set user details and this depends on how you run PHP with Nginx.
Nginx does not run PHP directly as Apache does and simply hands PHP requests to another separate process. This can be Apache as proxy or FastCGI using FPM etc. Whatever process it is that runs PHP is where the user issues have to be handled.
If serving as proxy to Apache, you set Apache up as you indicate and that is that. If FastCGI using FPM, then it will be in PHP FPM. Each pool conf file accepts “user” and “group”. To make this work for multiple domains, you just need to make one fpm pool per domain and each would listen on a different port.
So Domain 1 can be on Port 9001, Domain 2 or 9002 etc. Each will have a separate user and group as required.