I have centos 7 installed with nginx on a dedicated machine, running symfony (PHP) applications. Every site has its own user, in this example let's say its "user" in the "hostings" group. Application required console commands run like

$ php bin/console cache:clear

In this case the application's folder /var/cache will be created with "user:hostings" owner.

The problem is, when a visitor arrived on the site (nginx / webserver runs the application), it usually creates some additional files too in the same /var/cache directory, with "nginx:nginx" ownership.

So if one of the files are can't write with another's permission, it generates server 500 error.

What is the best scenario here? Should I change "nginx" user's group to "hostings" or "user:hostings" to "user:nginx" ? Or something else here?


Maybe your best bet is to run the PHP commands with user nginx in order for the directory to be created with nginx:nginx owner. The other option is to start the nginx service with user nginx but group hostings. Maybe you should take a look at How to configure PHP CLI on linux ubuntu to run as www-data?

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.