3

I have this weird problem related to permissions on a VPS where I run 2 Drupal 7 websites.

I have an old site, which was migrated over several hosting providers and VPS setups. I also have a freshly installed website.

The new one works perfectly and I can set it to aggregate and compress CSS files plus JavaScript files. All is smooth and without errors.

The old one... each time I set it to do this, It gives me errors such as:

The specified file temporary://filepIYgt4 could not be copied to public://js/js_IaQHoIpFqzgiVl19GZEd2HEQg6iqLy6d1_xllBmEbqE.js.
The specified file temporary://fileTbJH3r could not be copied to public://css /css_Lnc8IK4qbp4ueX76wBYIBGAqVihLWtCHHNP7WBSphEM.css.

Both websites are configured the same way. The difference though seems to be in the permissions set for the sites/default/files folder. The new website (which works fine) has the permissions set to 0777 and the group and owner are set to apache.

The old website (which generates errors) has the permissions set to 0777, the group to psacln and the owner is the user I'm using to login to the website via SSH or FTP.

If I change the owner and the group to apache for the old website, things still don't work. I get warnings like these:

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/css owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/js owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/ctools owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

As you can see, Drupal still can't write to the same troublesome folder. :(

What am I doing wrong? Any advice how to fix this?

3
  • Are they in the same environment? Was the old site has a recursive permission, I mean did you set it like this chmod 777 -R sites/all/files ? Also if possible try to clear your cache... Commented Jan 23, 2012 at 0:23
  • 1
    I am using WinSCP (I am not good at using the command line). In that tool, I check the option which says "set group, owner and permissions recursively". I noticed one more thing: the new website seems runs the processes that create the CSS and JS files using the apache user. The old site uses the user I created for it, which is part of the psacln group. Thus the 2nd error (described above) I get when changing the permissions for the default/files folder. Is this a problem related to the group the apache user belongs to? Commented Jan 23, 2012 at 10:39
  • I just thought of deleting the CSS and JS folders inside sites/default/files. Then, Drupal created them using the apache username. I made sure then to change the permissions to those folders to be full for the apache user and things still don't work. The first error I described is still present. I could not be more confused. :( Commented Jan 23, 2012 at 10:45

3 Answers 3

4

I managed to figure this out with the help of the company providing the hosting. So, I'm sharing the solution, in case others have similar issues.

The solution is to make PHP run as a "FastCGI application", instead of an "Apache module". This way, Drupal uses the same user I use to upload files via FTP, when it creates files, etc.

The new website worked fine because I used the one-click installer offered by the hosting provider, which ran everything using the apache user. The old website did not do this.

This solution & problem should apply to all hosting providers using Plesk.

4

As a website host provider we see this issue all the time. Most hosts that use cPanel will be running with suPHP which enables username.username on all files and directories. If you transfer a site in that doesn't use suPHP then all you need to do is chown -R yourcpanelname.yourcpanelname the sites/default/files directory.

Hope that helps.

-3

What worked for me was to navigate first to the user roles: People --> Permissions --> Roles

and then select the 'edit permissions' link for the particular role I wanted to edit.

So: Going straight to the Permission page where all roles are listed in columns did not work. But opening the permission page only for the particular role worked.

Cheers,

Pimmy

1
  • This answer has nothing to do with the question.
    – mbomb007
    Commented Jun 22, 2020 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.