PHP file permissions set to 600 instead of 644 when uploading to Symbiostock + Woocommerce on NGINX

I use a wordpress plugin for the sale of photographs that writes, through PHP, a file of images * .jpg in a directory “dir1” contained in wp-content / upload. The file is then to be downloaded by any user with the browser. The file should have 644 permission in order to be downloaded by any user. The problem is that the file is written with a permission of 600 and therefore a normal user cannot download it. The directory “dir1” has permission 755. Is it possible that the problem of writing the file with permission 600 instead of permission 644 depends on the PHP SAFE-MODE managed by Webmin-Virtualmin? How can I solve the problem?

PHP safe_mode: are you using PHP 5.4 or a version subordinate to that? Which OS are you using and which version of Virtualmin and Webmin do you have on your system? And which version of Wordpress?!

Thanks for your intervention.
I use Centos 8, PHP 7.4, Webmin 1.954, Virtualmin 6.11, Wordpress 5.5. Would you know how to solve the problem?

I use NGINX.

My prognosis is that it is the plugin that is is setting the permission of the file to 600 (owner read write). PHP safe_mode plays no role here. One reason the plugin could use 600 is to prevent hotlinking and to force a user to login to WordPress and access a file via the WordPress generated URL. If you wish to bypass this measure, you could do so by altering the script / plugin to set the file to 644 when it is created. You will then be able to access the file directly via a hotlinkable URL such as yourdomain.tld/upload/dir1/image.jpg or similar.

Thank you for your prognosis.
The site I installed on Virtualmin (With Nginx) is a mirror copy of a site running on a C-Panel. On C-Panel (with Apache) the problem does not arise. So I don’t think it depends on the plugin (Symbiostock + Woocommerce). According to the plugin manufacturer, the problem should be PHP. Do you have any idea?

Well, if the same script is running fine under Apache then it I would agree with the devs that the issue is with PHP. As a first and most non-intrusive step, could you hit Virtualmin -> Limits and Validation -> Validate Virtual Server and then use the tab Fix Permissions to make sure everything is ok with your install. Then try and upload a file, see if the permission is still 600?

If so, you will have to experiment with other, more intrusive, actions such as https://stackoverflow.com/questions/31610175/permission-on-files-created-by-nginx

Thanks for the tips.
The procedure: Virtualmin -> Limits and Validation -> Validate Virtual Server and then use the Fix Permissions tab didn’t solve the problem I always have 600 permissions on files.

I looked at the article: https://stackoverflow.com/questions/31610175/permission-on-files-created-by-nginx

On my system I could not find the php-fpm files in the sysconfig and init.d directories.
I found the php-fpm files in the following directories. Which ones should I change?

./run/php-fpm
./etc/logrotate.d/php-fpm
./var/log/php-fpm
./var/opt/remi/php74/log/php-fpm
./var/opt/remi/php74/run/php-fpm
./usr/sbin/php-fpm
./usr/share/licenses/php-fpm
./usr/share/doc/php-fpm
./opt/remi/php74/root/usr/sbin/php-fpm

I would have hoped that newly uploaded files will be 644 after Fix Permissions. The old files will continue to be 600, of course.

Let Virtualmin do it for you. Virtualmin -> Services -> PHP Configuration

I inserted umask code 002 in php.ini but the file generated for download has always allowed 600. Any other ideas?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.