Mobile app version of vmapp.org
Login or Join
Moriarity557

: Moodle error - Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting. I am running a Moodle 2.4.8 (Build: 20140113) on a Debian Squeeze box, with Apache

@Moriarity557

Posted in: #Moodle

I am running a Moodle 2.4.8 (Build: 20140113) on a Debian Squeeze box, with Apache 2.2. Whenever a user (even the admin user) makes changes to certain settings (i.e. adding a user), or just accessing certain courses (in this case, Math 9), the page pops up with a 503 error, Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting.

Checking my /config.php file, I see the path is set to /var/moodledata2, which is owned by www-data www-data, and permissions are lined up with the Moodle documentation.

This was intermittent at the start of the week, but now it's getting to be constant. There is lots of free space available (as shown below):

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md2 83G 37G 42G 48% /
tmpfs 2.0G 0 2.0G 0% /lib/init/rw
udev 2.0G 224K 2.0G 1% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/md1 939M 35M 857M 4% /boot
/dev/md3 822G 355G 426G 46% /var
/dev/md4 917G 72G 799G 9% /var/moodledata2

# cat config.php
<?php // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle2';
$CFG->dbuser = 'root';
$CFG->dbpass = '<removed>';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbsocket' => 0,
);

$CFG->wwwroot = 'http://example.com/moodle2'; // <removed>
$CFG->dataroot = '/var/moodledata2';
$CFG->admin = 'admin';

$CFG->directorypermissions = 0777;

$CFG->passwordsaltmain = '<removed>';

require_once(dirname(__FILE__) . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
#


I'm at a loss for what to do. Permissions seem logical in how they should be (www-data owning everything, and having full access to the /var/moodledata2 folder). What is my next step?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Moriarity557

2 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

I got the same error in Centos 7,
after this linux command ,It's working fine!

setenforce 0

10% popularity Vote Up Vote Down


 

@Radia820

Edit: Forgot to mention one of the obvious techniques. Read the server and program error logs for more information on specific problems. Errors displayed to the user through the frontend are often made intentionally generic.

To the solve the problem, find the files that are used in the failing processes by debugging the program (or ask the developers directly, might be the easiest route). One efficient way to debug a php program is to load it into a program like phpeclipse. Once you know the files causing the issue, check them individually for problems. You could be running into a corruption problem or an issue where files are not created by the program with correct ownership or permissions.

This link may help you get started on debugging: www.ibm.com/developerworks/library/os-debug/
Also make sure that the new files created in the data directory have the correct permissions and ownership. Sometimes a script is unable to create new data on the server because the running script doesn't have proper permissions to create new data because the data directory is too restrictive.

This would be my step 1: If none of the above works or seems too daunting, try moving the production site to a test server and see if you can replicate the problem. Even better if you can move it to a different operating system structure to help isolate server config vs program problems.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme