Problem with installation - moodledata directory

Problem with installation - moodledata directory

by Imre Urban -
Number of replies: 17

Hi. 

I would like to install Moodle on my web to use it for language teaching. I am not an IT guy. 

I start to install it in the web browser but I have problem with the moodledata directory.

At first it said: Parent directory (/home/urbanimrich) is not writeable. Data directory (/home/urbanimrich/moodledata) cannot be created by the installer.

I can create the moodledata directory only in the directory which is accessible from the web. But now it writes: Dataroot location is not secure. 

Anybodey who could help me?

Thanks.

Imi 



Average of ratings: -
In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Usman Asar -
Picture of Plugin developers Picture of Testers

Imi, windows setup or linux?

moodledata is always kept outside of wwwroot/public_html diretory, that is why it is showing warning, but not error.

keep it outside of where you have kept your moodle folder, and give write permissions.

In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Ken Task -
Picture of Particularly helpful Moodlers

+1 to Usman's response as it is the way to make it secure,  but if using a provider that won't allow moodledata outside of public_html (ie, your web root), try this:

https://docs.moodle.org/20/en/Creating_Moodle_site_data_directory

Could also talk to your provider ... good luck with that one! :\

'spirit of sharing', Ken

In reply to Ken Task

Re: Problem with installation - moodledata directory

by Imre Urban -

Thanks for info. 

After trying and checking I could create the data directory outside the web directories and I was able to go 1 step further in the installation process but after entering database data it does not work. I see only this message: 

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

What does it mean? And what to do now?

Thanks.

Imi




In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Imre Urban -

Ok. Now I am back in the beginning. Started once again. 

When I create a data directory in the root, it cannot be accessed by moodle. 

If I put the data directory to the main directory which can be accessed via web, it does not work. I tried to solve it by .htaccess file but it does not work or I put the .htaccess into a wrong directory (moodledata). 

Any idea how to solve this? 

In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Usman Asar -
Picture of Plugin developers Picture of Testers

are you hosted somewhere?

give permission 0777 to your moodledata directory keeping it outside of your public_html

if you are using a hosting company, then make use of script installer first to see if things  work the way it should

and regarding database, have you even created the database for moodle before actually proceeding with installation?


In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Ken Task -
Picture of Particularly helpful Moodlers

The .htaccess (which goes in moodledata IF moodledata directory is located in the directory where the moodle code resides) trick may not work on *all* remotely hosted systems.

Can you serve anything out of the directory where the Moodle code resides?   Create a phpinfo.php file that looks like this:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

Upload that to the directory where the moodle code resides then hit it with a browser.

If you get an error with that, what was the error?   Hint: make sure that the ownerships/permissions are set such that apache can see the files.   On remotely hosted systems like yours that might be your customer ID number or even your customer login name - that one could get from the provider, I would think.

So ... with whom do you host?    They might have an FAQ or customer area for customer use to post such issues and, hopefully, someone from the hosting providers technical department responds with their solution.   Many, however, take the easy way out and point customers over to these community forums for 'technical assistance' ... which, IMHO, is borders on criminal.    Anyhoooooo .... you don't have to be shy about the domain which you will be using ... heck, it's gonna eventually be on the web and unless you are doing some gov training or very hush/hush spy stuff no need ... Google (or some other search engine) will find it ... for sure.

So what is the domain you are using for the site?

Ok, now forum moderators might dis-agree ... let's hope they don't!    If they do and remove that info ... maybe they should be involved in assisting. ;)

Could be that you've chosen a hosting company that just will not work and thus you might have to seek some other service provider.

'spirit of sharing', Ken


In reply to Ken Task

Re: Problem with installation - moodledata directory

by Imre Urban -

I have uploaded the phpinfo.php to the directory where the moodle install.php is and I got a page with a lot of information. 

I have my webhosting at a small hosting company from Europe and I cannot get any help during the weekend. sad




In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Ken Task -
Picture of Particularly helpful Moodlers

Well, guess you'll have to wait until Monday then. :|  Unless fellow 'helpful' community user Usman has any ideas.

'spirit of sharing'. Ken

In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

So you can get to moodle but just not the moodledata folder?  Even when moodledata is in your web accessible folder?  That does not seem possible...did you redirect your config.php to the correct moodledata location?  Can you post error messages?

If using a .htaccess file, it should be located in your moodle folder, not your moodledata folder (in my experience anyway but maybe you are doing something different than I have used them for before).

In reply to Emma Richardson

Re: Problem with installation - moodledata directory

by Imre Urban -

If my moodledata direcory is in the  moodle folder (web accessible folder) and I put the .htaccess file into the moodle folder, I get this message when I start the installation:

500 Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.


If the .htaccess file is in the moodledata folder or there is no .htaccess file, then after starting the install process I get this message: 

Dataroot location is not secure

If I create the moodledata directory outside the web accessible folder, then I get this message, even that the moodledata folder has permission 777: 

Parent directory (/home/urbanimrich) is not writeable. Data directory (/home/urbanimrich/moodledata) cannot be created by the installer.

I cannot change the permission of /home/urbanimrich/. I have to contact the webhosting provider (answer from them will be on Monday or Tuesday).

I am installing the moodle patform first time. In the moodle folder there is no config.php file. If I am right, it will be created during the installation. 


Regards,

Imi




In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Ken Task -
Picture of Particularly helpful Moodlers

https://httpd.apache.org/docs/current/howto/htaccess.html
In the url above these secrtions:
When (not) to use .htaccess files
worth a read

How directives are applied

The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof. However, it is important to also remember that there may have been .htaccess files in directories higher up. Directives are applied in the order that they are found. Therefore, a .htaccess file in a particular directory may override directives found in .htaccess files found higher up in the directory tree. And those, in turn, may have overridden directives found yet higher up, or in the main server configuration file itself.

Most commonly, the problem is that AllowOverride is not set such that your configuration directives are being honored.

So .htaccess files are dependent upon AllowOverride config from main config file.

https://docs.moodle.org/20/en/Create_.htaccess_file
https://docs.moodle.org/20/en/Creating_Moodle_site_data_directory

There is, in moodle code, an htaccess file with some settings that users
could possibly use if the hosting situation warrants - but it doesn't have a line for moodledata.
moodlecode/lib/htaccess

which has this comment in the header:

# On some PHP servers it may help if this file is copied
# to the main moodle directory and renamed .htaccess
#
# As soon as you do this, check your web site.  Is it
# still working OK?  If you are getting a "configuration
# error" then you may need to enable overrides by editing
# the main httpd.conf for Apache and in the main server
# or virtual server area, adding something like:
#
# <Directory /web/moodle>
#     AllowOverride All
# </Directory>
#

'spirit of sharing', Ken

In reply to Ken Task

Re: Problem with installation - moodledata directory

by Imre Urban -

Dear Ken,

thanks for the info but I am lost. Maybe I have not a right .htaccess file and in my case I do not know what to insert into this file. 

My database and server data are attached. 

Regards,

Imi



Attachment my data.jpg
In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Ken Task -
Picture of Particularly helpful Moodlers

In a previous posting you showed: /home/urbanimrich/ is your home directory.

Is there a public_html directory (where user accounts can serve web stuff from)? [or something like it]   Providers don't have to do things the same way ... I see you are under VirtualMin ... which is a spin off of CPanel, Webmin etc. - but have no way of knowing how the provider has set up customers.

In VirtualMin, the provider can set things like apache's AllowOverRide variable to NONE - that means nothing you do with .htaccess files located anywhere will work.

Moodle code goes into some directory in your account that is already setup to allow web access.   For example ... notice that says example ... /home/urbanimrich/public_html/ would contain the moodle code.   If public_html directory doesn't exist, am willing to bet customer cannot create one manually.   In those moodle files, one will find a config-dist.php file which one could use to create the config.php file that Moodle would normally create when using the web based installer.    See notes in the config-dist.php file for how to use.

The moodledata directory, however, has to be manually created ***AND*** it cannot be in /home/urbanimrich/public_html/ *UNLESS* your provider has AllowOverRide turned on for options and is allowing that for all customer directories - your /home/urbanimrich/public_html/

Web based installer runs under apache user and doesn't have access levels to be able to create anything in your account.

The 'work-around' ***with some providers*** is to create the moodledata directory in /home/urbanimrich/public_html/ **where normally moodle code would complain about** AND to override that one would put an .htaccess file in moodledata that restricts just that directory from anyone browsing it.

That .htaccess file to contain:

order deny,allow
deny from all
Then copy the config-dist.php to config.php **AND** manually edit config.php filling out appropriate variables ... like paths, etc. DB user, DB, password, DB host, DB name, etc..  No one here would know specifics to those.   Then hit the moodle site via browser to finish the install ... basically moodle installer code setting up the DB.

But here again *** IF provider is not allowing any overrides in user directories ***, .htaccess files are ignored.

We can see you are hosted on Linux ... and it does look like there are more PHP extensions that need installation before one could completely install Moodle.

See: https://docs.moodle.org/29/en/PHP#PHP_Extensions_and_libraries

At this point, I'd say that you need to communicate directly with the provider.  We could guess all day long and still not get it right.

'spirit of sharing', Ken

In reply to Ken Task

Re: Problem with installation - moodledata directory

by Imre Urban -
My  root is /home/urbanimrich/. Here I can create files. I create moodledata and give permission 777. But I cannot change the permission on /urbanimrich/. 


My web page files are in  /home/urbanimrich/myweb.cz/konnyenmagyarul/

Here are my moodle files and directories as well. 

I have plaid around the .htaccess file and manually enetered to config.php the variables but it does not work. 






In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Just H -

What, if anything, do you have installed in "myweb.cz"?

If you have a Wordpress site or similar that could be the problem.

In reply to Imre Urban

Re: Problem with installation - moodledata directory

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

It sounds like your webhost is not allowing access from the web to folders outside of your public_html location.  Two options.

1. Despite the not secure message, will moodle allow you to continue?  I thought at some point moodle installer would no longer allow insecure dataroot but not totally sure...I know there are a lot of sites hosted that have this same issue and they just continue to run with the insecure location.  That is something that you will have to decide for yourself if the installer will  even let you continue this way.

2.  Talk to your host and explain your situation.  They should be able to give you another way to get the dataroot folder secure and accessible.

In reply to Emma Richardson

Re: Problem with installation - moodledata directory

by Imre Urban -

I have already wrote to my provider and explained what do I need. They will answer me on working days. I will see. 

Thank you for your help. 

Regards,

Imi