H
H
HellWalk2019-11-05 13:38:55
CentOS
HellWalk, 2019-11-05 13:38:55

CentOS + Nginx + PHP - permissions problem - what could be the reason?

I am deploying a project on symphony, on CentOS.
I get the classic first run error:

The stream or file "/var/www/site.loc/var/log/dev.log" could not be opened: failed to open stream: Permission denied

Usually, locally on Ubuntu + nginx, this problem is solved simply: chmod -R 777 /var/www/site.loc/var/
and that's it. At the same time, the user:group parameters for everything in www from the local user: walk:walk
On CentOS, control comes from root, and all user:groups go to root:root. And a simple prescription of rights 777 does not help.
I looked at the nginx config, from which user the work is happening. This is nginx
Changed www user:group recursively to nginx:nginx - the problem still remains.
ll at the root of the project shows this:
drwxr-xr-x.   6 nginx nginx     50 ноя  5 11:07 assets
drwxr-xr-x.   2 nginx nginx     36 ноя  5 11:07 bin
drwxr-xr-x.   3 nginx nginx     40 ноя  5 11:07 bundle
-rw-r--r--.   1 nginx nginx    402 ноя  5 11:07 codeception.yml
-rw-r--r--.   1 nginx nginx   3164 ноя  5 11:07 composer.json
-rw-r--r--.   1 nginx nginx 359496 ноя  5 11:07 composer.lock
drwxr-xr-x.   4 nginx nginx    116 ноя  5 11:07 config
drwxr-xr-x.   2 nginx nginx     32 ноя  5 11:07 docs
drwxr-xr-x.   7 nginx nginx     90 ноя  5 11:07 lib
drwxr-xr-x. 750 nginx nginx  24576 ноя  5 11:26 node_modules
-rw-r--r--.   1 nginx nginx    797 ноя  5 11:07 package.json
-rw-r--r--.   1 nginx nginx   1026 ноя  5 11:07 phpunit.xml.dist
drwxrwxrwx.   5 nginx nginx    163 ноя  5 13:08 public
drwxr-xr-x.  12 nginx nginx    190 ноя  5 11:07 src
-rw-r--r--.   1 nginx nginx  18130 ноя  5 11:07 symfony.lock
drwxr-xr-x.   6 nginx nginx     93 ноя  5 11:07 templates
drwxr-xr-x.   9 nginx nginx    214 ноя  5 11:07 tests
drwxr-xr-x.   2 nginx nginx     24 ноя  5 11:07 translations
drwxrwxrwx.   4 nginx nginx     30 ноя  5 11:09 var
drwxr-xr-x.  39 nginx nginx   4096 ноя  5 11:09 vendor
-rw-r--r--.   1 nginx nginx   2644 ноя  5 11:07 webpack.config.js
-rw-r--r--.   1 nginx nginx 234509 ноя  5 11:21 yarn-error.log
-rw-r--r--.   1 nginx nginx 301130 ноя  5 11:24 yarn.lock

What else can be done? Where to look for the cause of problems with rights?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2019-11-05
@HellWalk

Disable selinux and reboot.
Or write rules for selinux.

W
webvalman, 2020-10-12
@webvalman

Why chop off the shoulder and turn it off?
The problem lies in SELinuxe and its useful security policy.
In short, you need to add the necessary context to the directory so that Nginx can write logs there - httpd_log_t. I wrote more about the
solution at i.valman.org/2020/10/nginx-centos-selinux.html words and one comment do not lay down the whole meaning of the actions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question