Dataroot location is not secure

Dataroot location is not secure

by Danny "Real Deal" DuncanHines -
Number of replies: 24

I'm trying to install Moodle 2 on a server and I'm having trouble making the moodledata directory secure. I've installed Moodle before, but in that instance I had set the domain pointer to the /moodle folder and located moodledata in the actual web root. My problem is that now the domain is pointing directly to the web root and I'm not able to put the moodledata folder outside of it. I get the following error when I try to do so:

Parent directory is not writeable. Data Directory (/hermes/web07c/b1531/moodledata) cannot be created by the installer.

So I tried making a moodledata folder with an .htaccess file inside that says

order deny,allow
deny from all

as well as changing the permissions of the folder (I tried 770, 750, and 707), and none of this worked. I still get either the above error or another saying Dataroot location is not secure.

I'm using FatCow as a hosting service if this is any help.

Any help is much appreciated.

- Andy

Average of ratings: -
In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Andrea Bicciolo -

If you have your moodledata in the public web folder, I think you cannot get rid of the message unless you manage to move moodledata elsewhere, outside the web root.

You could try to create manually the moodledata folder outside the web space, then assign the web server user as the owner. Moving the moodledata involves updating config.php to reflect the new location.

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Tyler Bannister -
Picture of Core developers Picture of Plugin developers

Theis is a permissions/ownership issue in your data directory.  The best policy is probably to create the moodledata directory manually if you can.  You'll need to give the web server write permission to the directory to get moodle to work correctly you have 3 options:

1) Directory is owned by web server: 750

2) Directory is part of the web server group: 770

3) Directory is owned by you and part of your group: 777

The last one is obviously the least desireable, normally you want to use option #2.  That way you maintain ownership of the directory but the web server can also write to it.  You may need to contact your web host to get them to help you change group ownership on the directory.

In reply to Tyler Bannister

Re: Dataroot location is not secure

by Danny "Real Deal" DuncanHines -

Thanks for the info. I contacted my hosting service and they let me know that I can't access beyond the root folder, which means moodle data will have to reside inside. I changed the permissions of the folder to 770 and I'm still getting no love.

I talked to the hosting service further, and they suggested password protecting the moodledata folder via an .htaccess Editor. Will that actually work (or will Moodle be able to read/write data from the folder)? Seems kind of a weird workaround.

Ideas?

In reply to Tyler Bannister

Re: Dataroot location is not secure

by Danny "Real Deal" DuncanHines -

Any ideas yet? I still can't install anything. It seems like there would be more people running into this problem with something this basic to the functionality of Moodle. The documentation seems thorough enough, but it's not working correctly.

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Dagwin Roelants -

move the moodledata folder out of the public html directory.

Make sure read and write permissions are set on 777.

works perfectly and is secure

In reply to Dagwin Roelants

Re: Dataroot location is not secure

by Dagwin Roelants -

don't forget to modifie the config.php with the new location of the datafolder

In reply to Dagwin Roelants

Re: Dataroot location is not secure

by Danny "Real Deal" DuncanHines -

Right, I would move the folder out of public_html, but my web host, FatCow, doesn't allow that. You can't access beyond the web root. I need an alternate method and setting the permissions/including an .htaccess file in moodledata does nothing.

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

Maybe an alternative host?
<rant>You're their customer. They should give you what you want.</rant>

Does anything on this page help?
http://docs.moodle.org/en/Creating_Moodle_site_data_directory

In reply to Luis de Vasconcelos

Re: Dataroot location is not secure

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers
In reply to Luis de Vasconcelos

Re: Dataroot location is not secure

by Danny "Real Deal" DuncanHines -

UGH. This has been the most frustrating installation of Moodle ever.

So I got through the first step of clearing the moodledata folder. But THEN when I enter the database information in the next step, I get this error:

Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

I tried editing config-dist.php by hand and uploading it, but no dice again. The moodledata directory's permissions are set to 750. I have no idea what this error even means!

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

The Error means what it says...

$CFG->dataroot is not configured properly!

You must not be putting in the correct address for $CFG->dataroot

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Chris Clarke -

Hi,

I'm just in the process of setting up a moodle site using fatcow and experiencing the same problems you had. I was just wondering how you got around them in the end? (problems creating the data directory outside the website)

In reply to Luis de Vasconcelos

Re: Dataroot location is not secure

by Danny "Real Deal" DuncanHines -

Well I spent the first part of the afternoon on a Help Chat with the hosting provider, and it was some "internal error," which I guess means that I wasn't doing anything wrong per se. Apparently the path to the moodledata directory needed to have "/users" in it where the path to the moodle directory didn't, even though they're on the same level hierarchy-wise. Go figure.

Well I hope this thread will prove useful to someone!

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure

by Andreas Gounaris -

Same problem I had until I was adviced by my host provider to switch PHP support from Apache module to fastCGI. Then I was able to access directories outside wwwroot.

In reply to Danny "Real Deal" DuncanHines

unable to install moodle Re: Dataroot location is not secure

by Juan Marín -

I couldn't install moodle 2.0 R (and, as i can see, the problem is the same for 1.9.9 onwards).

My host (using PLESK IIS)  only let me to create folders inside httpdocs, but install.php couldn't continue: Dataroot location is not secure.

It is imposible to access root directory in my host, and I couldn't change the provider (so I HAVE to install the data directory inside the "public" folder or stop to use moodle).

As my server is windows, the .httpaccess don´t fix the security risks, I have to chage permissions. Now the "only" who have permission to access that folder is the Plesk IIS User (IUSR_Mydomain). This would be enought to have a secure access, right?. But  nothing changes and it is impossible to follow with the installation.

Has anybody have success installing moodle in ISS servers (all the ideas I found to fix my problem were for LINUX)?

It is possible to configure the config.php manually?

Thanks,

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure SOLUTION

by Paul Lovatt -

Quick way out of the moodledata security impasse! 

This has taken up the past EIGHT hours of my day and below is how I quickly solved the problem, with the help of my hosts 1and1.  Hopefully this will save others the sheer torment of an installation that will not proceed!!  I am on a linux shared server and do not have access to levels above my webroot (i.e. I can get into, but cannot see above, my htdocs/public_html folder).  I am not alone because I've been reading all the posts!

Skippable-rant: The web is full of people frustrated with Moodle and with their hosts because of this particular installation impasse.  It is utterly ridiculous that Moodle is configured to install in a way that will be defeated by most of the cheaper web hosts where access beyond the webroot is disallowed. Especially when the solution below is so simple.  Why on Earth is it not mentioned in the installation instructions!  

First, I had tried all the other offered solutions which have worked for some people but not for me: changing moodledata permissions to 750, 755, 700 etc; creating a .htaccess file etc.  No good.

My hosts 1and1 responded quickly (less than one hour) with the following suggestion which I am certain would also work on other hosts:

Regarding your Moodle installation, please change the destination of your [mydomain.co.uk] domain to "/moodle" to resolve the problem in the moodledata folder section. After changing the destination of the domain, please give it about 3-5 minutes for the server to refresh and after that, proceed with the installation. To change the destination of the domain, please follow the steps provided in the link below.

http://faq.1and1.co.uk/domains/domain_admin/domain_dest/2.html

As I say, this worked, and would work similarly for other hosts I am sure.  I chose to point my domain at moodle, as they suggested.  Obviously, this will not be the solution everybody wants.  But there is the option to create another folder for the domain to point at, and put moodledata alongside it and moodle itself (and any other sites using the same domain) inside it.  This creates a level of invisibility above the moodle folder that satisfies the installer!

This would work (with your domain configured to point here *) if you want to run your moodle as http://yourdomain.com/moodle:

  1. /htdocs (no access above this point)
    1. /magicfolder1*
      1. /moodle
      2. /otherwebsite1
      3. /otherwebsite2
    2. /moodledata

In my case, my moodle is now to be found at http://mydomain.co.uk/ which works fine for me:

  1. /htdocs (no access above this point)
    1. /moodle*
    2. /moodledata

Kind of obvious when we think about it!  So somebody with the permissions please add it to the installation instructions!

Paul

In reply to Paul Lovatt

Re: Dataroot location is not secure SOLUTION

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I think the key words in your post were

"most of the cheaper web hosts "

I wouldn't buy hosting with that limitation. I pay £50 per year (approx USD $80) and it does what I need.

In reply to Marcus Green

Re: Dataroot location is not secure SOLUTION

by Paul Lovatt -

Your lucky to be paying less than me.  All very well, but this is where VERY MANY people are at if you have read as many posts across the web on this very issue as I have.  There is no crime in paying $10 dollars a month, as I do, which is clearly not the cheapest and about right for the level of traffic I am expecting.  You don't always know as a user what the limitations are until you hit them.

The point is that the Moodle install program gave up and provided me with no further hint as to what to do.  Problem now solved.

 

In reply to Paul Lovatt

Re: Dataroot location is not secure SOLUTION

by Guillermo Madero -

Hi Paul,

The final point behind what Moodle does is to protect (main keyword here) from public access what's saved in moodledata.

The recommendation you have provided will surely allow the installation to finish, but it is just a workaround that will not provide any real protection (as it will just act as security through obscurity).

In reply to Guillermo Madero

Re: Dataroot location is not secure SOLUTION

by Paul Lovatt -

Hi Guillermo,

I appreciate what you're saying and also that I should not post into more than one forum.  It's just that there are a lot of desperate people out there with the same basic issue.  Perhaps I should have posted a link back to the first forum. Forgive me for being new to posting here.  There is more than one forum on this issue, all providing good advice but none solving the problem for me, or a lot of others.  When I say it took me eight hours to find the actual solution to this problem I mean it!

Regarding the security of the solution we are discussing: I am clearly not an expert, but most of the solutions proposed in the installation instructions and these various forums (changing file permissions, 700, 770 etc to moodledata within the htdocs folder) are at the same level, of being surely not that secure.  There is nothing to stop people applying these solutions to the moodledata folder just the same. 

The thing is: we can get the installation to proceed!

 

 

In reply to Paul Lovatt

Re: Dataroot location is not secure SOLUTION

by Guillermo Madero -

Hi Paul,

Been there, spending hours and days trying to find the solution to some problem (in my case it was with the backup process).

I do agree with you, it is a good solution, as the objetive is to finish the installation process; however, it's good to at least warn the user and let her/him know that the moodledata folder will be unprotected.

Cheers!

In reply to Guillermo Madero

Re: Dataroot location is not secure SOLUTION

by Paul Lovatt -

Can someone who knows more than me clarify this point: How would someone access my moodledata folder if they wished to do so, given that my domain points past it to the moodle folder.  Would they do it through my IP address?

Am I right to assume that an appropriate .htaccess file and the right permissions (as referred to in the installation instructions/various posts) could still be used to 'protect' the contents?  Would that still be less than secure?

If those who work on the installer were to prevent even this solution in the future and demand that moodledata be located outside of the htdocs or public_html folder, then the instructions would have to make this absolutely clear at an earlier stage.  Moodle would then effectively be dictating to users that they could not install on certain servers or packages (probably a high percentage of them).  I am probably not alone in doing things in this order: get familiar with moodle --> buy a hosting package --> install moodle.  I need to know to ask this question before I rent the webspace.

In reply to Danny "Real Deal" DuncanHines

Re: Dataroot location is not secure [SIMPLE SOLUTION]

by Christian Thompson -

I had the same problem using Plesk; I could not write to a folder outside the website root.  Rather than play around with config files on my server (as suggested in other threads), I simply modified the installer script (install.php) to skip the data root check.

To do so, open install.php in a text editor.  Search for the following line of code (on my Moodle 2.3 install it was line 305):

}elseif(is_dataroot_insecure()){

 Change it to the following:

}elseif(FALSE){

Save it, upload to your server, and run the installer.  The script will now skip this check and you can proceed.

Of course, do this at your own risk; the check is there for a reason. At a bare minimum, set your data directory permissions to 770; this should provide a reasonable amount of security.

This same check existed in 1.x, but you had the option of ignoring it.  I would suggest displaying a stern warning and bringing this option back.

Good luck!

 

Average of ratings: Useful (3)