title: Error installing moodle. Dataroot location is not secure and Parent directory (/var) is not writeable.
body: <p>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. </p>
  
  <p>I've tried placing it in <code>/var/moodledata</code> which gives me an error saying <code>
  Parent directory (/var) is not writeable. Data directory (/var/moodledata) cannot be created by the installer.</code>
  and at <code>/var/www/moodledata</code> which gives me an error saying <code>Dataroot location is not secure</code></p>
  
  <p>I tried giving sudo(permissions) to the <code>/var/www/</code> folder and also  tried hacking <code>install.php</code> to skip the validation by commenting out the following lines</p>
  
  <pre><code>/*while(is_dataroot_insecure()) {
      $parrent = dirname($CFG-&gt;dataroot);
      $i++;
      if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i &gt; 100)) {
          $CFG-&gt;dataroot = ''; //can not find secure location for dataroot
          break;
      }
      $CFG-&gt;dataroot = dirname($parrent).'/moodledata';
  }*/
  </code></pre>
  
  <p>and</p>
  
  <pre><code>       /* do {
          if ($CFG-&gt;dataroot !== '') {
              $prompt = get_string('clitypevaluedefault', 'admin', $CFG-&gt;dataroot);
          } else {
              $prompt = get_string('clitypevalue', 'admin');
          }
          echo $error;
          $CFG-&gt;dataroot = cli_input($prompt, $CFG-&gt;dataroot);
          if ($CFG-&gt;dataroot === '') {
              $error = get_string('cliincorrectvalueretry', 'admin')."\n";
          } else if (is_dataroot_insecure()) {
              $CFG-&gt;dataroot = '';
              $error = get_string('pathsunsecuredataroot', 'install')."\n";
          } else {
              if (install_init_dataroot($CFG-&gt;dataroot, $CFG-&gt;directorypermissions)) {
                  $error = '';
              } else {
                  $a = (object)array('dataroot' =&gt; $CFG-&gt;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-&gt;dataroot, $CFG-&gt;directorypermissions)) {
          $a = (object)array('dataroot' =&gt; $CFG-&gt;dataroot);
          cli_error(get_string('pathserrcreatedataroot', 'install', $a));
      }
  }*/
  </code></pre>
  
  <p>However, I havent had any success . Any idea on how I could over come this would be appreciated!</p>