Directory permissions (Moodle 2.4)

Directory permissions (Moodle 2.4)

by Ricard Siliuk -
Number of replies: 7

Hello,

I'm configuring a copy of a website and I get this error in php_errors.log  when trying to access the website:

PHP Fatal error: uncaught exception 'invalid_dataroot_permissions' with message "Invalid permissions detected in $CFG->dataroot directory"

For now, the permissions on the moodledata folder are set to 0777 but even that doesn't change the outcome. Is it looking for specific set of permissions or maybe I messed up the user? For the time being I've set the owner of both moodle ar moodledata to root for testing purposes. 

Average of ratings: -
In reply to Ricard Siliuk

Re: Directory permissions (Moodle 2.4)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
How do you configure the copy? According to https://docs.moodle.org/en/Moodle_migration, for example?

The message means, Moodle has a conflict with the operating system. Therefore it is interesting to know on which exactly? If a Unix flavour, 0777 sounds like one, tell exacly which derivate, distribution, version.

Assuming Unix, also post the output of "ps -uax | grep apache" and "ls -ld /path/to/moodledata".
In reply to Visvanath Ratnaweera

Re: Directory permissions (Moodle 2.4)

by Ricard Siliuk -

I wasn't aware of the tutorial, so I simply copied the files, and exported/imported the mySQL database (which is now properly configured, I think, no errors on that one now). I'm working on Debian 7 Wheezy.


Output of your commands are:

  1. warning: bad ps syntax, perhaps a bogus '-'?
  2. root     16475  0.0  0.4 177736  9896 ?        Ss   12:02   0:00 /usr/sbin/apache2 -k start
  3. www-data 16477  0.0  0.5 178756 10816 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  4. www-data 16478  0.0  0.2 177768  6152 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  5. www-data 16479  0.0  0.2 177768  6152 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  6. www-data 16480  0.0  0.2 177768  6152 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  7. www-data 16481  0.0  0.2 177768  6152 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  8. www-data 16499  0.0  0.2 177768  6152 ?        S    12:02   0:00 /usr/sbin/apache2 -k start
  9. ricard   17252  0.0  0.0   7840   880 pts/3    S+   13:08   0:00 grep apache
  10.  
  11.  
  12. drwxrwxrwx 165 root root 4096 Nov 26 17:15 /var/moodledata


Should I also post my config.php? 

Also, I gave 0777 permissions and ownership of the folders to root - should I change that to www-data instead?

In reply to Ricard Siliuk

Re: Directory permissions (Moodle 2.4)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
It shows that the apache2 processes run as user www-data, typical in Debian and derived distributions.

Your moodledata is owned by root and make writeable by apache through the third seven in 777. The ownership and permissions here allows a whole spectrum of possibilties. If you are looking for the most strict one, read https://docs.moodle.org/19/en/Security#Most_secure.2Fparanoid_file_permissions.
In reply to Visvanath Ratnaweera

Re: Directory permissions (Moodle 2.4)

by Ricard Siliuk -

Sorry for late appearance, last week in University takes priority. 

I changed owner of datadir (moodledata) by "chown" command like so:

chown www-data /var/moodledata


By the way, should I also change group of the folder? Right now owner is reported as www-data and group is reported as root.

Still, there error about permissions is the same. Anything else I am missing? On an unrelated note, where should moodledata be? Is it better to store in

/var/moodledata
or
/var/www/moodledata

I'm also attaching error log if it helps.

  1. [16-Dec-2014 16:27:03 Europe/Helsinki] PHP Fatal error:  Uncaught exception 'invalid_dataroot_permissions' with message 'Invalid permissions detected in $CFG->dataroot directory, administrator has to fix permissions.' in /var/www/www/moodle/lib/setuplib.php:1278
  2. Stack trace:
  3. #0 /var/www/www/moodle/lib/setuplib.php(1360): make_writable_directory('/var/moodledata...', true)
  4. #1 /var/www/www/moodle/cache/stores/file/lib.php(155): make_cache_directory('cachestore_file...')
  5. #2 /var/www/www/moodle/cache/classes/factory.php(264): cachestore_file->__construct('default_applica...', Array)
  6. #3 /var/www/www/moodle/cache/classes/helper.php(152): cache_factory->create_store_from_config('default_applica...', Array, Object(cache_definition))
  7. #4 /var/www/www/moodle/cache/classes/helper.php(137): cache_helper::initialise_cachestore_instances(Array, Object(cache_definition))
  8. #5 /var/www/www/moodle/cache/classes/factory.php(234): cache_helper::get_cache_stores(Object(cache_definition))
  9. #6 /var/www/www/moodle/cache/classes/factory.php(183): cache_factory->create_cache(Object(cache_defin in /var/www/www/moodle/lib/setuplib.php on line 1278

In reply to Ricard Siliuk

Re: Directory permissions (Moodle 2.4)

by Colin G -

try this:

chown www-data:www-data /var/moodledata -R

Does not really matter where you store moodledata but /var/www/moodledata would be my preference out of those 2 locations.



In reply to Ricard Siliuk

Re: Directory permissions (Moodle 2.4)

by Colin G -

Generally you should not be doing chown 777 for security reasons. This is usually bad especially on shared hosting.