After installing moodle on to our website and while accessing the website we might get below error:

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

Now to solve the issue edit the file config.php and check "$CFG->dataroot" path,

this path must be correct and must have the location path of moodledata.

Insert the correct path of moodledata and save the file and now access the website, you will find that the error is gone!!