Installing and upgrading help

dataroot is not writable, admin has to fix directory permissions

Picture of 06S01at14163 itservice
Re: Data directory cannot be created by installer(c:/inetpub/wwwroot/moodledata)

Today I ran into the same error.

After a while i got the idea.

On any linux box such as Red Hat, Cent OS, fedora and Co there is a pretty good likelihood that SELinux is enabled and enforced.

First of all you should check the directory and file permissions. Being at least accessible and readable to the web server - most often apache. Dirs and files should be owned by apache:apache.

The SELinux  is quite consequent. I therefore  ran into this issue after relabelling the system.

In case that after permission setting the web server still does complain about

„$CFG->dataroot not writable“ 

look at the SELinux labels of the dirs and files in $CFG->dataroot.

They are displayed with the CLI

ls -lZ /full_path_of_dataroot 

All labels should be

apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0  4096  1. Dez 14:21 cache
The httpd_sys_rw_content shows that the dir or file is writeable.

In case this is not given execute

sudo chcon -R -t httpd_sys_rw_content_t /full_path_of_dataroot
This will change the file context recursively to the type httpd read/write.

Reload the webpage.

Average of ratings: -
Picture of Dean Thayer
Re: Data directory cannot be created by installer(c:/inetpub/wwwroot/moodledata)

If you have SELinux enabled, this advice from 06S01at14163 itservice is excellent. You may find that your next problem after configuring SELinux to allow write access to $CFG->dataroot will be a database connection failure. If so, you will need to configure SELinux to allow httpd to connect to your database with this command:

setsebool -P httpd_can_network_connect_db on

I also recommend this article from Red Hat and this article from Oracle for more on how to succeed with SELinux on LAMP servers.

Average of ratings: -