5

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!

seeker
  • 6,841
  • 24
  • 64
  • 100

5 Answers5

6

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.

franzlorenzon
  • 5,845
  • 6
  • 36
  • 58
2

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.

sumit
  • 332
  • 2
  • 7
2

Note this line from the Moodle 2.6 installation guide;

IMPORTANT: This directory must NOT be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient.

create the 'moodledata' directory in a directory on your server that is not publicly accessible via the web ie not within your httpdocs or public directory.

Matt
  • 106
  • 5
1

i tried this and it working for me try this..,

in moodle root go the install.php and if you are using 2.6 in line 341 or others versions search for is_dataroot_insecure() function and change it to false in the else if condition and try to install again,and thats it..,(note This not the best way of doing this but coding hack to just get rid of this error if you like try it..)

wordpresrox
  • 590
  • 11
  • 31
0

try running the following commands from the terminal Debian users

sudo mkdir /var/moodledata

chmod ugoa=rwx /var/moodledata