0

I am facing an error when trying to run a project developed in Moodle. It's showing "Invalid permissions detected" when trying to create a directory. "Turn debugging on for further details." This error. I have run this command, "chmod 0777 /var/www/html/e-learning" to enable write permission, but still doesn't work. Can any one suggest? Thank you.

  • use `sudo chmod 777 /var/www/html/e-learning` – vatsal mangukiya Dec 20 '22 at 09:08
  • `chmod 777` is a VERY BAD advise! On the server the folder/files should be owned by the relevant (web) user, and permissions for folders should be 755 or 751 depending on the setup... always stay away from 777 – Ron Dec 20 '22 at 11:31

1 Answers1

0

It's probably the data directory not the web directory

https://docs.moodle.org/401/en/Installing_Moodle#Create_the_.28moodledata.29_data_directory

Look for this value in config.php

$CFG->dataroot = '/var/yourmoodledatadirectory';

Then change permissions

sudo chmod -R 0777 /var/yourmoodledatadirectory

Also add this to config.php

$CFG->directorypermissions = 02777;

You might also need to change the ownership of the data directory

sudo chown -R www-data /var/yourmoodledatadirectory

Also, 777 for the web directory isn't recommended, use 755 instead

sudo chmod -R 0755 /var/www/html/moodle
Russell England
  • 9,436
  • 1
  • 27
  • 41
  • if 777 is not recommended, why do you recommend it in your instructions? Also `chmod 777` with `-R` (recursive) is again a VERY BAD IDEA – Ron Dec 20 '22 at 11:35
  • 1
    777 is required for the Moodle data directory, it's literally in the instructions for Moodle - https://docs.moodle.org/401/en/Installing_Moodle#Create_the_.28moodledata.29_data_directory – Russell England Dec 20 '22 at 11:39
  • That does not make it good practice. This might be the way they insure that their product will work, but that is NOT the correct or necessary way for the folder to be set. If the permissions and the ownership of the folder is proper, then Moodle will still work without issues, but not allow Others to have read+write ... – Ron Dec 20 '22 at 12:35
  • As far as I know, the data folder does not sit somewhere the web can access, hence the permissions are set for the filesystem outside the www directory, I don't see that actually being an issue, if you're going to say it's a bad idea at least explain. – Hugo Jun 22 '23 at 12:03