General help

Error: Invalid permissions detected when trying to create a directory [solved]

 
Matt Bury
Error: Invalid permissions detected when trying to create a directory [solved]
Particularly helpful MoodlersPlugin developers

Hi,

I've found this problem elsewhere on the forums but not with a satisfactory solution or explanation.

My server environment:

  • VPS: Ubuntu 16.0 LTS
  • latest versions of Apache MySQL (as of April 2018)
  • PHP (7.2) with additional modules installed and enabled
  • MySQL InnoDB format = Barracuda
  • Moodle v 3.4.2

Environment passes all Moodle checks.

Migrated data from another server, i.e.:

  • mysqldump DB backup
  • /var/www/moodledata/filedir
  • /var/www/moodledata/geoip
  • /var/www/moodledata/lang
  • /var/www/moodledata/lock
  • /var/www/moodledata/muc
  • /var/www/moodledata/repository

File permissions:

  • /var/www/html: chown = root:root; chmod = directories 755; files 644.
  • /var/www/moodledata: chown = www-data:www-data; chmod = 777

The whole site was up and running for ~1 week before I started getting the following error increasingly until the whole site stopped working:

Invalid permissions detected when trying to create a directory.

I read here: https://moodle.org/mod/forum/discuss.php?d=343116#p1386751 (2016-12-05) that it might be an opcache issue. Which I took to mean that opcache was unable to write files to:

  • /var/www/moodledata/cache,
  • /var/www/moodledata/localcache,
  • /var/www/moodledata/sessions,
  • /var/www/moodledata/temp,
  • and/or /var/www/moodledata/trashdir

I connected to the server via CLI and did the following:

$ chown www-data:www-data -R /var/www/moodledata
$ chmod 777 -R /var/www/moodledata

And the issue immediately went away. Nobody else had accessed the server before the issue arose. So somehow, the file permissions got changed without any intervention from me or anyone else.

Is this a known bug in Moodle? I couldn't find a similar one in the bug tracker.

Thanks in advance,

Matt smile

 
Average of ratings: -
Picture of Matteo Scaramuccia
Re: Error: Invalid permissions detected when trying to create a directory [solved]
Core developersParticularly helpful MoodlersPlugin developers

Hi Matt,
are you running Moodle cron via CLI?
If yes, check you're running it under the same user thew web server is running on (here www-data): https://docs.moodle.org/34/en/Cron#Finding_the_right_place_to_put_the_command or https://askubuntu.com/questions/189189/how-to-run-crontab-as-userwww-data#210545 .

HTH,
Matteo

 
Average of ratings: Useful (1)
Matt Bury
Re: Error: Invalid permissions detected when trying to create a directory [solved]
Particularly helpful MoodlersPlugin developers

No I'm running cron as root. Would this mean that the owner of any directories created by the cron script being run as root would be root?

I'll change it to www-data.

Thanks Matteo smile

 
Average of ratings: -