Error installing moodle. The location of Dataroot is not safe, and the parent directory (/ var) cannot be written.

I try to install moodle, but I encounter an error in the process when I specify the path to the moodle data folder. Mostly they want it to be in a place where it cannot be accessed from the Internet.

I 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. Parent directory (/var) is not writeable. Data directory (/var/moodledata) cannot be created by the installer. and with /var/www/moodledata , which gives me an error saying Dataroot location is not secure

I tried granting sudo (permissions) to the /var/www/ folder and also tried to hack install.php to skip checking by commenting out the following lines

 /*while(is_dataroot_insecure()) { $parrent = dirname($CFG->dataroot); $i++; if ($parrent == '/' or $parrent == '.' or preg_match('/^[az]:\\\?$/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 had no success. Any idea on how I can do this would be greatly appreciated!

+4
source share
4 answers

You can create the directory yourself.

I assume you are using Ubuntu or Debian. From the walkthrough to install Moodle on Ubuntu:

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

Where www-data is the user used by your web server.

+3
source

Pay attention to this line from the Moodle 2.6 Installation Guide ;

IMPORTANT: this directory SHOULD NOT be available directly over the Internet. This will be a serious security hole. Do not try to put it inside your web root directory or inside the directory of Moodle program files. Moodle will not be installed. He can go anywhere.

create the "moodledata" directory in a directory on your server that is not publicly accessible over the Internet, i.e. not in your httpdocs or public directory.

+2
source

As you mentioned

/ var

This place is not writable, so the web server does not have write permission here, so therefore moodledata is not created there. Make sure the web server has write permission here.

If you create moodledata in

/ var / www

This is a place that is not safe because it can be easily obtained from the Internet. Data may be stolen.

+1
source

I tried this and it works for me, try this.,

in configle root, run install.php, and if you use version 2.6 on line 341 or other versions to search for the is_dataroot_insecure() function and change it to false in the case of else if and try to install again, and this .., (note that is not the best way to do this, but coding is hacked to just get rid of this error if you like to try it.)

+1
source

Source: https://habr.com/ru/post/1501726/


All Articles