Moodle under Windows, dataroot and file_exists

Moodle under Windows, dataroot and file_exists

by Claude Paroz -
Number of replies: 8

(Windows 2000, IIS) Whenever I try to produce content needing to be saved in the data directory of moodle, I'm getting the error :

Warning: mkdir(D:\Inetpub\moodledata) [function.mkdir.html]: File exists in D:\Inetpub\wwwroot\moodle\lib\moodlelib.php on line 1429
ERROR: You need to create the directory D:\Inetpub\moodledata with web server write access

The directory exists, and the NT permissions are total. It seems that the PHP function file_exists return false, even if the directory exists and is reachable.

Do you know a workaround for this ?

Claude

Average of ratings: -
In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Moodle definitely works out-of-the-box on W2000 with IIS. Have you tried creating the directory outside of is IIS folders, say just D:\moodledata, changing config.php to suit?
In reply to Howard Miller

Re: Moodle under Windows, dataroot and file_exists

by Claude Paroz -

I just tried, but with same result.

I suspect a bug in the PHP version (4.3.4). The file_exists function seems to always return false on a directory on Windows. Moodle then tries to create the folder (mkdir) and receive an error as the folder already exists.

In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
you could be right..... I have had a 'Google' around, and there seems to be issues about the forward/backward slashes. There seems to be anecdotal evidence that some PHP file commands fail on IIS when there are forward slashes in paths. I'll have a dig around though and see if there's an answer as it clear works for most (many?) people.
In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Just a thought...

Check in your php.ini file. Have you got the directive open_basedir set to anything. If you have and don't have a good reason comment it out and restart everything. That would be too easy though smile

Can you take out the passwords and post a copy of your config.php file here too please - just in case!
In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Dimitris Kokkas -

I have the same problem and I found a solution.
I've changed the possition of the shared folder from D: to C: drive and......... everything just worked fine.
I can't undertand why this is happening. The permissions to the shared folders on both drives are identical so maybe its a bug of the program.

The problem still persists to me because I only have space for uploading on D: drive so If anyone have any idea of what to do please reply.

In reply to Dimitris Kokkas

Re: Moodle under Windows, dataroot and file_exists

by Claude Paroz -

This solution didn't resolve anything for me.

Yes, I have checked the openbasedir setting in php.ini, but it is commented out.

Here's a copy of our config.php (without comments) :

<?PHP // $Id: config-dist.php,v 1.52 2004/03/12 07:34:14 moodler Exp $
unset($CFG);  // Ignore this line

$CFG->dbtype    = 'mysql';       // mysql or postgres7 (for now)
$CFG->dbhost    = 'localhost';   // eg localhost or db.isp.com
$CFG->dbname    = 'moodle';      // database name, eg moodle
$CFG->dbuser    = *****;    // your database username
$CFG->dbpass    = *****;    // your database password
$CFG->prefix    = 'mdl_';        // Prefix to use for all table names

$CFG->dbpersist = false;         // Should database connections be reused?
                                 // "false" is the most stable setting
                                 // "true" can improve performance sometimes

$CFG->wwwroot   = 'http://rpntest1.rpn.ch/moodle';

$CFG->dirroot   = 'D:\Inetpub\wwwroot\moodle';

$CFG->dataroot  = 'C:\moodledata';

$CFG->directorypermissions = 0777;

$CFG->admin = 'admin';


//=========================================================================
// ALL DONE!  To continue installation, visit your main page with a browser
//=========================================================================
if (file_exists("$CFG->dirroot/lib/setup.php"))  {       // Do not edit
    include_once("$CFG->dirroot/lib/setup.php");
} else {
    if ($CFG->dirroot == dirname(__FILE__)) {
        echo "<p>Could not find this file: $CFG->dirroot/lib/setup.php</p>";
        echo "<p>Are you sure all your files have been uploaded?</p>";
    } else {
        echo "<p>Error detected in config.php</p>";
        echo "<p>Error in: \$CFG->dirroot = '$CFG->dirroot';</p>";
        echo "<p>Try this: \$CFG->dirroot = '".dirname(__FILE__)."';</p>";
    }
    die;
}
?>

In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Claude Paroz -

I eventually discovered that it works only when the dataroot folder resides below the Docroot folder of the Web server. As mentioned by the installation documentation, it's not a good security practice...

It's probably a PHP matter, but has nothing to do with the open_basedir directive.

In reply to Claude Paroz

Re: Moodle under Windows, dataroot and file_exists

by Kevin Lawry -

It probably wont  help you much, but I can say that I run under windows and things work as expected, although I am still running PHP 4.2.0

In case it helps I have attached a snippet of my config file that shows the settings I use