In the old, shared server system I was, my username as A. Each PHP script in my site was run with my own username:

$puser = posix_getpwuid(posix_geteuid())['name']; // = $puser = "A";

Now I run my own VPS which runs nginx and the username/group is nginx.

However I 've created a friend's account with username B and I want each PHP script he creates to execute with user B, not nginx. Basically I want each PHP script to be run with the UID of the same user that created it.

Is that possible with nginx ?


With bare nginx, you cannot do it based on file ownership only.

PHP-FPM is the script execution engine that is used with nginx.

In PHP-FPM, there are PHP worker pools, which can be set up in different ports. Each PHP-FPM worker can have a user that is used to execute scripts for that pool.

Then, in nginx side, one configures rules which PHP-FPM backend is used for which request. The normal configuration is that each virtual host on nginx uses its own PHP-FPM worker pool.

With bare nginx, it is not possible to check file ownership so that backend location could be selected with that information. nginx lua module could be used for this purpose though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.