3

I seem to be regularly running into problems with file permissions running on WordPress. The two specific examples are that image browsing and upload didn't work in KCEditor (due to permissions for KCFinder) and the tracked links in bulk mailings were failing. In both cases I got 500 errors from the browser. I found that I needed to change directory permissions to 755 from 775 and file permissions from 664 to 664 in appropriate places. It seems rather random whether directory/file permissions are 775/664 or 755/644.

I think this is due to the way my hosting provider sets up WordPress and does not allow 775/664 permissions and from what I read this will be a common situation with hosting providers that use suexec.

Changing file permissions manually is a work around, but tedious and unreliable. I may be missing some and things not working properly because of this, but not being so obvious. And when it comes to an upgrade I'll have to go through it all again.

Is there a reason why the WordPress CiviCRM is distributed with these file permissions? Is there a reason for the variation in file permissions (and what is the logic)?

If this can't be changed in the distribution, can I safely change all 775 to 755 and all 664 to 644 and how might I do this?

I don't think the versions are relevant, but this applies to CiviCRM 4.7.24 and WordPress 4.9 and also other recent versions earlier this year. The hosting provider is SiteGround.

1 Answer 1

2

It depends under which user your hosting provider is running the web server (or the PHP process if using FPM). Sometimes the web server runs as your user, sometimes it runs as a generic www-data/httpd user. If you have ssh access and your user can view processes, you can run:

ps aux | grep -E '(www|http|apache|php)'

(many cpanel-type hosting providers might not even let you see the list of processes)

In any case, I think it's safe to default to:

  • Any files/directories with php files should be 755/644
  • Other directories, where there might be uploads, cache files, logs, should be 775/664. For example: wp-content/uploads/civicrm/.

Related questions:

3
  • That's helpful. But I guess I'm going to need to write a script to do the changes on each update. I'll have to work out exactly what needs changing. I'm not clear what you mean by (ex: files/civicrm) is ex: example or except! And I can't find that directory which looks to me as if it might be Drupal rather than WordPress.
    – Mick Kahn
    Commented Nov 29, 2017 at 17:02
  • Bad habit. I corrected my answer/example :)
    – bgm
    Commented Nov 29, 2017 at 19:12
  • My hosting provider has run a script for me to change all the files to 755/644 and that seems to have resolved the problem and, as yet had no negative effects (though I haven't used it much. I'm not sure about the directories you suggest having as 775/664 because they are set to 755/644 in the distribution and seems OK. Will post my script when I have tried it on a clean site to see exactly what it changes.
    – Mick Kahn
    Commented Nov 30, 2017 at 18:08

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.