Moodle Install Issue

Moodle Install Issue

by Murali Sriram -
Number of replies: 7
Moving moodle from one server to another server. When I use the below config, I am having an exception and can't load the application. Help is appreciated.

When I remove the $ in the folder structure and moved to different folder application is working fine. But I need to incorporate $ in the floder. Let me know how can i fix this error by not removing the $

Below is the config and the error message I see when I use the config directory in commented section.


$CFG->dbtype    = 'sqlsrv';

$CFG->dblibrary = 'native';

$CFG->dbhost    = 'xxxxxx';

$CFG->dbname    = 'xxxx';

$CFG->dbuser    = 'xxxx';

$CFG->dbpass    = '$@#xxxx';

$CFG->prefix    = 'mdl_';

$CFG->dboptions = array (

  'dbpersist' => 0,

  'dbport' => 1433,

  'dbsocket' => '',

);


$CFG->wwwroot   = 'http://xxxx/xxxx';

//$CFG->dataroot  = 'D:\\WebSite$\\Apps\\xxxx';

$CFG->dataroot  = 'D:\\www\\xxxx';

$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;

require_once(__DIR__ . '/lib/setup.php');


Error Message: 

Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.
Average of ratings: -
In reply to Murali Sriram

Re: Moodle Install Issue

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
So you are saying that your commented out line is actually where the site is located? You cannot use a dollar sign because that is signifying something in the code of this file. Rename your folder or trying using quotes around the reference maybe...
In reply to Emma Richardson

Re: Moodle Install Issue

by Murali Sriram -
Hello Emma,

Thanks for the replay. I tried using a different folder and able to load the aplication without any issues. But we host all our applications oin Website$, so is there any other solution to use the foilder with $ ?
Attachment Picture.JPG
In reply to Murali Sriram

Re: Moodle Install Issue

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

I think the $ should be allowed because it's in single quotes. In double quotes PHP would treat $ as part of a variable name.

As far as I can see this should work, Moodle passes $CFG->dataroot to the PHP function realpath(). If that function returns false then you get the $CFG->dataroot is not configured properly… error. The PHP documentation says realpath() will return false on Microsoft Windows when the path is a shortcut more than one level away ("On Windows, junctions and symbolic links to directories are only expanded by one level.").

I haven't got a D: disk but on my test server realpath() returns a non-false (OK) value for 'C:\\Website$\\Apps\\XXX'.

Is the directory on your server a shortcut or a real directory? If you know how to run PHP scripts using the command line you could try this:

<?php
$CFG = new stdClass();
$CFG->dataroot = 'D:\\Website$\\Apps\\XXX';

if (realpath($CFG->dataroot)) {
        echo "Directory OK" . PHP_EOL;
} else {
        echo "Directory error" . PHP_EOL;
}

If you don't get Directory OK then there's a problem either with your server or possibly your PHP environment.

Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Moodle Install Issue

by Murali Sriram -
Hello Leon,

Thanks for your response. I tried testing the PHP Script and able to get the good response from the server. Also I verified the realpath and able to navigate to the application.

Any other solution for this?

<?php
echo realpath('D:\\WebSite$\\Apps\\eADAPCourse_Data\\'), PHP_EOL;
?>
-----------------------------------------------------------------
<?php
$CFG = new stdClass();
$CFG->dataroot = 'D:\\Website$\\Apps\\eADAPCourse_Data';

if (realpath($CFG->dataroot)) {
        echo "Directory OK" . PHP_EOL;
} else {
        echo "Directory error" . PHP_EOL;
}
Attachment Test.JPG
In reply to Murali Sriram

Re: Moodle Install Issue

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The only other thing I can think of is copying those test scripts – realpath.php and Test.php – into the Moodle source code folder and accessing them through a browser (for example: https://mymoodle.example.com/realpath.php) to see if the results are any different in case the web server is blocking access for some reason.

As far as I can see the only way that specific Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting. error can occur is if the realpath() check of $CFG->dataroot returns false.

In reply to Leon Stringer

Re: Moodle Install Issue

by Murali Sriram -

Leon,

I tried the way you suggested for test.php and realpath.php.

For Test.php, I got direcotry error and realpath.php, a blank page appeared.


Attachment test directory.JPG
In reply to Murali Sriram

Re: Moodle Install Issue

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

That indicates that when these scripts are being run by the web server the access to D:\Website$\Apps\eADAPCourse_Data is not available for some reason, unlike when you run the scripts at the command line and the access is available.

The obvious scenario where this could happen is if the web server is running in some containerized environment where the D:\Website$\Apps\eADAPCourse_Data directory is presented as some different directory path.

We'd need to more about your web server to help further, firstly please tell us what web server software you're using, for example: Apache or IIS? And whether any containerization is involved.