Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing moodle. Dataroot location is not secure and Parent directory (/var) is not writeable.

Tags:

php

moodle

I'm trying to install moodle but I come across an error in the process, when I specify the path to the moodle data folder. Basically they want it be at a place where it cannot be accessed from the web.

I've tried placing it in /var/moodledata which gives me an error saying Parent directory (/var) is not writeable. Data directory (/var/moodledata) cannot be created by the installer. and at /var/www/moodledata which gives me an error saying Dataroot location is not secure

I tried giving sudo(permissions) to the /var/www/ folder and also tried hacking install.php to skip the validation by commenting out the following lines

/*while(is_dataroot_insecure()) {
    $parrent = dirname($CFG->dataroot);
    $i++;
    if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
        $CFG->dataroot = ''; //can not find secure location for dataroot
        break;
    }
    $CFG->dataroot = dirname($parrent).'/moodledata';
}*/

and

       /* do {
        if ($CFG->dataroot !== '') {
            $prompt = get_string('clitypevaluedefault', 'admin', $CFG->dataroot);
        } else {
            $prompt = get_string('clitypevalue', 'admin');
        }
        echo $error;
        $CFG->dataroot = cli_input($prompt, $CFG->dataroot);
        if ($CFG->dataroot === '') {
            $error = get_string('cliincorrectvalueretry', 'admin')."\n";
        } else if (is_dataroot_insecure()) {
            $CFG->dataroot = '';
            $error = get_string('pathsunsecuredataroot', 'install')."\n";
        } else {
            if (install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
                $error = '';
            } else {
                $a = (object)array('dataroot' => $CFG->dataroot);
                $error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
        cli_error(get_string('pathsunsecuredataroot', 'install'));
            }
        }

    } while ($error !== '');*/
} /*else {
    if (is_dataroot_insecure()) {
    }
    if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
        $a = (object)array('dataroot' => $CFG->dataroot);
        cli_error(get_string('pathserrcreatedataroot', 'install', $a));
    }
}*/

However, I havent had any success . Any idea on how I could over come this would be appreciated!

like image 589
seeker Avatar asked Sep 11 '13 19:09

seeker


2 Answers

You can create the directory yourself.

I assume you're using Ubuntu or Debian. From the step-by-step guide to install Moodle in Ubuntu:

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

Where www-data is the user used by your webserver.

like image 177
franzlorenzon Avatar answered Sep 20 '22 19:09

franzlorenzon


As you mentioned

/var

This location is not writable so web server does not have write permission here so that why moodledata is not created there. Make sure web server has write permission here.

If you create moodledata in

/var/www

This location that is not secure because it can be accessed from web easily. Data can be stolen.

like image 20
sumit Avatar answered Sep 20 '22 19:09

sumit