The 'Data Directory' you specified could not be found or created.

The 'Data Directory' you specified could not be found or created.

by Roy Pointflex -
Number of replies: 15
I am using Fedora. Just tried installing moodle(latest version) but when it comes to specify the Data Directory i get this error message "The 'Data Directory' you specified could not be found or created. Either correct the path or create that directory manually." I tried creating the directory manually, i also tried changing the path but to no avail. It just can't seem to find or create a data directory(moodledata). Please help me correct this issue as i am newbie to moodle.
Average of ratings: -
In reply to Roy Pointflex

Re: The 'Data Directory' you specified could not be found or created.

by Jesus Padro -

What you need to do is to create a new directory (moodledata) outside of your sites root directory (eg. /srv/www/htdocs/(moodle install))

Create your moodledata directory within the next step down from the root dir. eg /srv/www/moodledata be sure to chown this directory so you have rights to it. That is all that needs to be done.

In reply to Jesus Padro

Re: The 'Data Directory' you specified could not be found or created.

by Roy Pointflex -
Thanks Jesus for your quick reply, but i resolved this issue by configuring the config-dist.php myself(which isn't difficult), and it works. I would suggest this method to anyone who has this same problem too... Thanks anyways
In reply to Jesus Padro

Re: The 'Data Directory' you specified could not be found or created.

by Tom Simpson -
I just installed Moodle 1.8 on Ubuntu 7.10
I had the same error with data directory not found
I created another moodledata directory per Jesus's suggestion
it worked!
I had been banging my head on the computer keyboard for 3 days!
Thanks

unfortunately once the site was up and I started to add users and courses
I added curl per the Moodle recommendations and now the site won't load
looks like the 8th installation will be next


In reply to Tom Simpson

Re: The 'Data Directory' you specified could not be found or created.

by Jennifer Mackenzie -

I hve done the same, and set the read write access but still can't get it to work. have also been banging my head against various objects: ia m getting the following error message. I would really appreciate any help. Thanks

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/www/vhosts/mydomain/private/moodledata) is not within the allowed path(s): (/var/www/vhosts/mydomain/httpdocs:/tmp) in /www/vhosts/mydomain/httpdocs/tefl/courses/lib/setuplib.php on line 130

Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/www/vhosts/mydomain/private/moodledata) is not within the allowed path(s): (/var/www/vhosts/mydomain/httpdocs:/tmp) in /www/vhosts/mydomain/httpdocs/tefl/courses/lib/setuplib.php on line 131
ERROR: You need to create the directory /www/vhosts/mydomain/private/moodledata with web server write access

ERROR: You need to create the directory /www/vhosts/mydomain/private/moodledata with web server write access

ERROR: You need to create the directory /www/vhosts/mydomain/private/moodledata with web server write access

In reply to Jennifer Mackenzie

Re: The 'Data Directory' you specified could not be found or created.

by Ken Wilson -

Hi Joe

FYI, the open_basedir restriction prevents execution of PHP scripts outside the allowed paths. To remove the error you're getting, the directory containing the moodle code and moodledata needs to be in the open_basedir string.

Can you please try using your hosts control panel to edit your php.ini file and look for the open_basedir setting. Change it by adding the path to moodledata so that it looks like the following (the text in red are the changes):

open_basedir = '/var/www/vhosts/mydomain/httpdocs:/tmp:/www/vhosts/mydomain/private/moodledata'

If you cannot change the php.ini file, find out from the hosting company how you can configure the open_basedir setting. They should suggest either using a .htaccess file or a php.ini file located in your /var/www/vhosts/mydomain folder. It's difficult to know which one to suggest as it is dependent on the server settings, so best to ask them.

Let us know how things go!

Ken

In reply to Ken Wilson

Re: The 'Data Directory' you specified could not be found or created.

by James Walker -
Thanks for the tip Ken. I am using OpenSource to host my Moodle install. I am trying to install 1.8.5 and get the "Data Directory" message. I have created the moodledata file twice in the /home/mypath/moodledata and set the file as writable. I use CPanel and FTP. How do I find the open_basedir file?

Thanks
Jim
In reply to James Walker

Re: The 'Data Directory' you specified could not be found or created.

by Richard Enison -
JW,

By OpenSource I presume you mean OpenSourceHost.com. I have been to their website and went from one page to another all over it, and so far I haven't found any indication as to whether their customers (such as yourself) have access to their php.ini file, but that is where open_basedir is defined, if that's what you mean by "the open_basedir file". So I will assume that you do have access. The only question, as you say, is where it is.

I believe the simplest way to find the active php.ini file (I am assuming, again, that you are using php5, not php4, so that there is only one active php.ini file), which works on all kinds of systems (Linux, Windows, etc.), is to run the phpinfo script (see http://docs.moodle.org/en/phpinfo). You should find the pathname of the file near the top of the page, identified as "Configuration File (php.ini) Path".

RLE
In reply to Jennifer Mackenzie

Re: The 'Data Directory' you specified could not be found or created.

by Tarik Dzekman -

Hi,

It appears you are on a Vhosts setup. Your problem can be helped with a vhosts.conf file in your domain/conf/ directory.

I had the same installation problems a few days ago and wrote up a guide on how to install Moodle on a vhosts setup:

http://moodle.org/mod/forum/discuss.php?d=96069

In reply to Tarik Dzekman

Re: The 'Data Directory' you specified could not be found or created.

by Jennifer Mackenzie -

Thanks, i will try this as soon as i get access to the conf directory!!!

In reply to Jesus Padro

Re: The 'Data Directory' you specified could not be found or created.

by Pol Monsó -
I was having the same issue on my first contact on moodle. I'm a real newbie on it, but, how can the browser access the directory if permissions are set to 770? Shouldn't them to be set to 775 (and maybe switching them back afterwards?). That's what I did to make it work, am I leaving some security holes there? I'll put permissions back to 770 as soon as I'm done with the installation. I'm just running moodle on localhost for development purposes, so security it's not my main concern, I'd like to do things properly though.

btw, moodledata is outside the moodle directory and owner set to nobody, it didn't help.
In reply to Pol Monsó

Re: The 'Data Directory' you specified could not be found or created.

by Richard Enison -
PM,

I wouldn't say there was a giant security hole in using 775 instead of 770, though 770 is certainly more secure. The difference between 775 and 777 is that it doesn't allow users outside the group that owns the file or directory to write to it. If the permission is 770, those outside the group cannot do anything with it, not even read or execute it.

So the critical thing, if you use 770, is who owns the directory that has that permission mode? You say you set the owner of moodledata to nobody, but is nobody the user your web server (probably Apache) runs as? If you have access to the Apache configuration file (probably httpd.conf), you can look at it in a text editor; look for a line that begins User. That line will tell you what Linux user Apache will run as if you launch it as root. If you launch it as any other user (than root), it will run as that user.

Not only moodledata, but the Moodle directory (and all its subdirectories) should be owned by the user Apache is running as. Otherwise, if the permission for those directories is 770, it will not be able to serve any of the Moodle pages and your web browser will get a "403 Permission denied" error.

RLE
In reply to Richard Enison

Re: The 'Data Directory' you specified could not be found or created.

by Pol Monsó -
I get a flooding of mails since I wrote to this post. I missed your answer I'll check where in preferences is that set...

Back to the point, Apache has splitted its configuration files, so httpd.conf is empty now. Do you know where to find what user would apache be ran from? Or any keyword that would be on the same line so I could grep it? running ps aux | grep apache shows 6 apache processes (no wonder why is it that...?) the first running as root and the others as www-data. Everything inside moddledata is owned by www-data except the directory itself, which is owned by nobody:nogroup.

Changing the owner to www-data:www-data and setting 770 work nice&clean. Thank you for your support!
In reply to Pol Monsó

Re: The 'Data Directory' you specified could not be found or created.

by Richard Enison -
PM,

I frequently don't get e-mails of posts in forums I subscribe to also; I'm told that this usually happens because the moodle.org servers are down for preventive maintenance, but sometimes, it is because my mail server gets a bug in their bonnet about such e-mails needing to be blocked. See Tracker issue MDLSITE-393.

Anyway, it is normal for several .conf files to be used with Apache, the main one being httpd.conf (usually) and the others referenced with include directives in that main file. Sometimes, Apache is compiled with a switch that specifies a different name for the main .conf file. If you don't know which file it is, how will you know which file to grep? So I presume you do. Anyway, the keyword to grep for is User. That specifies the user Apache will run as if launched by root. If it is launched by any other user, it runs as that user.

As for the multiple Apache processes, that is one of the two ways webservers handle the multiple requests from web browsers all over the world that come in at the same time. The other way is to use one process with multiple threads. It looks like in your case, Apache was launched by root which resulted in the parent process running as root. The actual work is being done by the child processes running as user www-data, group www-data.

RLE
In reply to Richard Enison

Re: The 'Data Directory' you specified could not be found or created.

by Gary Gopi -
Hi,

I also have the similar problem and have the moodledata folder outside of the moodle directory and nothing works..

Can anyone provide a detailed guide to resolve this problem?

Thanks.

Gary
In reply to Gary Gopi

Re: The 'Data Directory' you specified could not be found or created.

by Richard Enison -
GG,

So many different problems have been raised in this thread, it is unclear what you mean by "the similar problem". However, since you mention your moodledata directory, I presume you are referring to the original problem of the thread, as spelled out in the subject line.

First of all, having the data folder outside the moodle folder is a good idea, but it has absolutely nothing to do with this error. It is good because of security reasons.

Secondly, make sure the value assigned to $CFG->dataroot in config.php (moodle folder) is correct, i.e., it should be the complete pathname to the data directory you say you have. [EDIT: You might post that value, or maybe your entire config.php (with your database p/w, at least, removed!), so we can see if there is a problem with it.]

Third, make sure the permissions for that directory, and all subdirectories, are adequate. See Installing Moodle/Creating a Moodle site data directory.

Finally, see http://moodle.org/mod/forum/discuss.php?d=84369#p372906. EDIT: and maybe other posts in that thread.

RLE