S
S
Sergey Khlopov2020-11-08 18:20:55
Nginx
Sergey Khlopov, 2020-11-08 18:20:55

How to make PHP-FPM create folders with permissions 775 and files with 664?

Hello, please tell me, there is a project on laravel, I set up nginx and php-fpm, I created a new pool for the site:
/etc/php/7.4/fpm/pool.d/dev-my.conf

Contents of the dev-my.conf file

[dev-my]
user = dev-my
group = dev-my
listen = /run/php/php7.4-dev-my-fpm.sock
listen.owner = dev-my
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /


As I understand it, now the scripts on the site are run on behalf of the user dev-my, the problem is that if my php script creates a folder or files, then the folders are created with rights - 755, and files - 644, but I would like the folders to be with rights 775 and files from 664.
And it's still not clear to me:
There is such a folder in laravel /storage/framework/viewsin this folder there are cached view files.
What am I doing:
  1. I clear the views folder from files
  2. I go to the main page of the site through a browser, files with 644 permissions have been created in the views folder
  3. Again I clear the view folder from files
  4. I connect via SSH under the user dev-my, execute the command: php artisan view:cacheI look in the views folder, there are now files with 664 rights

Why the rights are so different I don’t even know. I already tried to google php-fpm umask, the examples that are did not work for me. Please tell me what could be the problem? Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nokimaro, 2020-11-08
@nokimaro

1. You can set in scripts - umask() , but you need to be extremely careful and understand what you are doing
2. In php-fpm.conf you can also set umask = 0002 (to get 664) see How to change umask for user www- data in debian 7?
3. The "default" umask value can be set for the user with the umask command (for example, via ~/.bashrc), for cases when you execute commands in the artisan console after logging in, dev-mysee How to set the default umask?

V
vreitech, 2020-11-08
@fzfx

I can only suggest a solution to the problem by means of administration. try

setfacl -R -m d:g:<имя группы>:rwx /storage/framework/views

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question