'Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting

unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype    = 'sqlsrv';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'my remote db ip address';
$CFG->dbname    = 'remote database name';
$CFG->dbuser    = '****';
$CFG->dbpass    = '**********';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
    'dbpersist' => 0,
    'dbport' => 1433,
    'dbsocket' => '',
);
$CFG->wwwroot   = 'http://localhost/LMS';
$CFG->dataroot  = 'C:\\inetpub\\LMSdata';
$CFG->admin     = 'admin';
$CFG->directorypermissions = 0777;

This is my configuration in config.php. I'm using moodle 3.2 in IIS with php 7. Remote SQL server version 2012.



Solution 1:[1]

The webserver does not have write permission to the folder ( C:\inetpub\LMSdata).Please modify the permission of the dataroot folder and allow write permission. This will solve the issue.

Solution 2:[2]

How to allow your moodle data write permission.
Please follow these steps
For that please go to /var/www/moodledata or if any path where you defined the moodle data then just paste this command

sudo find . -type d -exec chmod 777 {} \;

I hope this will solve your permission problems

Solution 3:[3]

If you use IIS 10, you can do like this. enter image description here

The simple solution is to this problem is to change the NTFS permissions on the moodledata folder to allow write/modify to any user who is using moodle (I just set ours to domain users).

Solution 4:[4]

Make sure 'inetpub' and 'inetpub' directories already exists

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gnuwings
Solution 2 Arslan Maqbool
Solution 3 Huynh Cong Tru
Solution 4 AminFarajzadeh