• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Files uploaded via php are unmanageable by Plesk or ftp

jerrac

New Pleskian
PRODUCT, VERSION, MICROUPDATE, OPERATING SYSTEM, ARCHITECTURE
11.5.30 Update #51, last updated at July 24, 2015 01:25 AM
Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-86-generic x86_64)
PHP 5.4.42

PROBLEM DESCRIPTION
When I upload a file via a php script, Drupal 7 in my testing, the file ends up owned by www-data, and in the www-data group. This means that I cannot manage the uploaded files via the Plesk UI, or via FTP/SFTP.

STEPS TO REPRODUCE
Install a php script like Drupal 7 that lets you upload files. The uploaded files will be owned by www-data.

ANY ADDITIONAL INFORMATION
I did try setting php to run as FastCGI, mod_php, and CGI. Neither option helped. Uploaded files were still owned by www-data.

I did manually restart Apache after I set php to use FastCGI.

Any suggestions?
 
Yes. That's one of the reasons I tried FastCGI.

My public files directory is 777, <myuser>:psacln.

Public files get uploaded with 664, www-data:www-data.

Inside is my private files directory, drupalroot/sites/default/files/private, created by Drupal. It is 755, www-data:www-data.

Uploaded files in the private files directory are 664, www-data:www-data.

All of that is the way it is supposed to be, or, at least, it would be on a non-plesk server.

When I turned FastCGI on, I expected uploaded files to be <myuser>:psacln. Or something like that.
 
Hi jerrac,

did you try the suggestion, to change all folders to the permissions: domain-system-user : psacln ?

Source: https://groups.drupal.org/node/140969

The suggestion from the Drupal - forum is:
Comments
Permissions
Posted by oadaeh on April 9, 2011 at 1:08pm

This is all you should need to do:

First, temporarily give group and other write access to the settings.php file with this command: chmod ugo+w settings.php (I added the user for good measure.)

Next, manually create the files directory and give the group write access with this command: chmod -R ug+w settings.php (The "-R" says to do it recursively.)

After your installation is done, remove all write access to settings.php with a similar command to the first one: chmod ugo-w settings.php

You can check to make sure you have everything correct on the Reports -> Status report page.

To explain the "Drupal behaviour": The files inherit the permissions from your folder, so the uploaded files should have the same permissions, as your folder.
 
... another solution is to use:

usermod -a -G psacln www-data

This will add the systemuser www-data to the psacln group and should solve your issue as well. This is as well usefull, if you use php5-fpm.
 
Hi jerrac,

did you try the suggestion, to change all folders to the permissions: domain-system-user : psacln ?

Source: https://groups.drupal.org/node/140969

The suggestion from the Drupal - forum is:


To explain the "Drupal behaviour": The files inherit the permissions from your folder, so the uploaded files should have the same permissions, as your folder.

No. That solution will not work for me. The users who are effect do not have the ability to manually edit file permissions. They certainly cannot run chmod. Manually changing the owner:group to match the sftp user and psacln would definitely let me deal with the files via sftp. But normal users cannot do that. Hence why I did not try.

Also, I did create the <drupalroot>/sites/default/files directory on my local machine, and then uploaded via sftp. So it has always had <domain-system-user>:psacln owner:group.

... another solution is to use:

usermod -a -G psacln www-data

This will add the systemuser www-data to the psacln group and should solve your issue as well. This is as well usefull, if you use php5-fpm.

Erm, Plesk didn't do that automatically? Oh. Do I need to restart anything to make the change take effect? Modifying a file did not work after I ran the usermod command.

Though, since Drupal made the private directory with 755 permissions, the group will not have write access. So I'd have to manually give that directory group write permissions... Again, not something normal users can do.

So, yeah, lots of ways to fix this for a sys admin like me. But it's not so easy for normal users...

We really need php to create the files and directories with an owner:group of <domain-system-user>:psacln. That's what I though FastCGI was supposed to do. Is setting the PHP support dropdown in "Hosting Settings" not enough?
 
Back
Top