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!
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.