PHP writes files with 600 permissions instead of 644

I use some plugins that through PHP write files in / wp-content / upload / direcory1. I noticed that PHP writes files with 600 permissions instead of 644 permissions as it should be.

The only way to write with 644 permissions is to go to the Virtualmin> Server Configuration> Website Option tab and change the PHP execution mode from fcgi-cgi to FPM and then and back to fcgi-cgi.

I wonder if it's a bug and if it can be fixed. I tried to put umask 0002 in the PHP config file but didn't get any results.

After a few hours the website crashes and the page shows this error

 waiting for available sockets

.

System: CentOS Linux 8.2.2004 PHP 7.4 NGinx 1.14.1

Thanks for the attention.

Status: 
Closed (fixed)
Virtualmin version: 
6.12
Webmin version: 
1.955

Comments

Ilia's picture
Submitted by Ilia on Wed, 10/21/2020 - 16:27

Hi,

I wonder if it's a bug and if it can be fixed. I tried to put umask 0002 in the PHP config file but didn't get any results.

What you're looking for is the mask 022, which will create files to be writable by owner, and only readable by group and world (644).

In order to change the mask for FCGI you would need to edit its wrapper script(s) in /home/domain/fcgi-bin (note that those files are immutable) and set the mask to umask 022. It's worth mentioning, that it should be set as this by default already. It also can be managed via System Settings > Edit Templates > PHP wrapper scripts as defaults for new domains.

However, we suggest using PHP-FPM execution mode, and to change default umask for FPM service you can do the following :

systemctl edit php-fpm

.. add the following in the opened editor :

[Service]
UMask=0022

.. and then reload :

systemctl daemon-reload
systemctl restart php-fpm
systemctl restart nginx