Moodle with IIS 6

Moodle with IIS 6

by Octavian Brinzea -
Number of replies: 21
I have a server with windows 2003 server on it.The server hosts multiple sites and it was not configured by me from the beginning so i don't have any idea about the settings on IIS.

I want to install moodle so to be accesed for example www.mywebsite.com/moodle.
I followed this tutorial http://www.moodlewindows.za.net/index.htm but it did not work for me.

Thank You
Average of ratings: -
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Octavian Brinzea -

i've tried again using the same tutorial and i think i'm very close....but i get this error:

Error detected in config.php

Error in: $CFG->dirroot = '/home/example/public_html/moodle';

Try this: $CFG->dirroot = 'E:\moodle';

although in the config.php it is written $CFG->dirroot = 'E:\moodle';

after i refresh the page i get this error:

PHP Notice: Undefined property: stdClass::$dbfamily in E:\moodle\lib\setuplib.php on line 261 PHP Notice: Undefined property: stdClass::$dbfamily in E:\moodle\lib\setuplib.php on line 281

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

Considering that you used the MoodleWindows tutorial, I'm assuming that you're using FreeTDS to connect to MSSQL - you are using MSSQL, aren't you?

Did you specify the dbtype as 'mssql_n'?
i.e.:
$CFG->dbtype = 'mssql_n';

Does the output of the PHPInfo() command show a MSSQL section?

What else do you have in your Moodle config.php file?

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -
i've changed to $CFG->dbtype = 'mssql_n';

thee config file was taken from moodle site and modified as it is said in the tutorial.
i don't know what is the problem yet.
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

Ok, try this:

Backup and then delete your config.php file. Then run the Moodle setup. It will detect that you don't have a config.php file and it will prompt you for all the values that it needs to create one.

Does that work?

***

Something to play with if the above doesn't work:
(Note: Tread with caution - I'm not a Moodle developer, or even a PHP programmer!)

To me the "Undefined property: stdClass::$dbfamily in E:\moodle\lib\setuplib.php on line 281" error says that a valid value for dbfamily has not been returned by the $dbtype switch statement on line 243 of the moodle\lib\setuplib.php file and there is no 'default' option in the switch statement to catch any invalid values. So you're getting the error because you haven't specified a valid value for $CFG->dbtype in the config.php file.

That $dbtype switch statement only checks for 7 values: 'mysql', 'mysqli', 'postgres7', 'mssql', 'mssql_n', 'odbc_mssql' and 'oci8po'. Whatever you have specified as your dbtype in the config.php file doesn't match one of those 7 values and that's why you're getting the error message.

Try adding an extra default statement to that $dbtype switch statement in the setuplib.php file:

switch ($dbtype) {
    case 'mysql':
    case 'mysqli':
        $CFG->dbfamily='mysql';
        break;
    case 'postgres7':
        $CFG->dbfamily='postgres';
        break;
    case 'mssql':
    case 'mssql_n':
    case 'odbc_mssql':
        $CFG->dbfamily='mssql';
        break;
    case 'oci8po':
        $CFG->dbfamily='oracle';
        break;
    default:
        echo "You must specify a valid value for $CFG->dbtype in config.php";

        break;

}

Then add an if (empty(...)) check to the switch ($dbtype) statement in the set_dbfamily() function in your \Moodle\lib\setuplib.php file:

function set_dbfamily() {

    global $CFG, $INSTALL;

    // Since this function is also used during installation process,
    // i.e. during install.php before $CFG->dbtype is set.
    // we need to get dbtype from the right variable
    if (!empty($INSTALL['dbtype'])) {
        $dbtype = $INSTALL['dbtype'];
    } else {
        $dbtype = $CFG->dbtype;
    }

    switch ($dbtype) {
        case 'mysql':
        case 'mysqli':
            $CFG->dbfamily='mysql';
            break;
        case 'postgres7':
            $CFG->dbfamily='postgres';
            break;
        case 'mssql':
        case 'mssql_n':
        case 'odbc_mssql':
            $CFG->dbfamily='mssql';
            break;
        case 'oci8po':
            $CFG->dbfamily='oracle';
            break;
    }

    if (empty($CFG->dbfamily)) {
        print_error('missingdbtype');
    } else {
      return $CFG->dbfamily;
    }

}

And then add this to the bottom of your \Moodle\lang\en_utf8\error.php file:

$string['missingdbtype'] = 'An invalid value was specified for the dbtype parameter in your config.php file';

What happens when you run the Moodle setup after making these changes?

WARNING! I haven't extensively tested all this and I'm not a Moodle developer... and there could be better ways to do the error handling... so don't try this on a production box! big grin

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -
I've done what you have suggested.I deleted the config.php from moodle folder and i managed to enter the instalation but when i reach the database step, i get this error:

PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL.Please check you php.ini file or recompile PHP.

i will try to look again in php.ini maybe i will fix it myself but any advices are good.

Thank you very much Luis de Vasconcelos for your answers.
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Octavian Brinzea -
Hmmm solve it.I've modified my php.ini.

Unfortunately another error occurred:We could not connect to the database you specified.Please check your database settings.

I've fill in this way:

Type:SQL Server with UTF-8 support (mssql_n)
Host Server:localhost
Database:moodle
User:myuser
Pass:mypass
Tables prefix:mdl_

Any suggestions ?
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

What did you modify in your php.ini file?

What kind of database are you using - MySQL or MSSQL (i.e. MS SQL Server)? I'm assuming you're using MSSQL because you used the MoodleWindows setup guide. If that's correct, does the output of PHPInfo() display a MSSQL section?

Is your database server running on localhost? Which version of MSSQL are you running?

Assuming that you're using FreeTDS... have you enabled the FreeTDS extension in your php.ini file:

extension=php_dblib.dll

And have you created the freetds.conf file and configured it properly?

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -
I am using MySQL Server 2005 as said in the tutorial.I have enabled the extension for FreeTDS and also created the .conf file.

I'm not sure where to put this freetds.conf file....in the tutorial says that in the root.My home directory si E:\moodle.....cand i put the freetds.conf there or is it wrong ?
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

MySQL Server 2005???

Do you mean MS SQL Server 2005 (Microsoft SQL Server 2005)?

Put the freetds.conf file in E:\ if that is your root (i.e. drive where you've installed Windows). If Windows is installed on the C:\ drive then put it in C:\

Don't put it in E:\moodle - The PHP engine won't be able to find it there...


Read the FreeTDS docs for more info http://www.freetds.org/userguide/freetdsconf.htm

It basically says "FreeTDS will look for a file .freetds.conf in the user's home directory"...

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -
yes...i'm using Microsoft SQL Server 2005

i've putted fretds.conf in E:\ ...put same error.
In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

What have you got in your freetds.conf file?

Does the output of PHPInfo() show a MSSQL section?

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -

this is what i have in freetds.conf

[global]
host =127.0.0.1

port = 1433
client charset = UTF-8
tds version = 7.0
text size = 20971520

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Luis de Vasconcelos -

It looks ok...

Add this to the end of the file and restart IIS:

dump file = C:\Moodle\FreeTDSDebug.log
debug level = 1

It will turn on the FreeTDS logging option which might help find your problem. Then try to run the setup again and then inspect the log file to see if it shares any secrets.

Remember to turn this logging option off again when you've got the problem solved. The log file gets really big really fast so you don't want to have the logging option switched on all the time.

Finally, does the output of PHPInfo() show a MSSQL section?

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by dung tran -
1. download http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip
2.extract to the folder PHP\ext
3.3. Edit your /PHP/php.ini file and add this line:
 extension=php_dblib.dll

Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).

4. Create a file called C:\freetds.conf with:

 [global]
 host = xxx.xxx.xxx.xxx (ip of the MSSQL server)
 port = 1433
 client charset = UTF-8
 tds version = 8.0
 text size = 20971520

5. Your Moodle config.php should include lines like these:

$CFG->dbtype = 'mssql_n'; // Required
$CFG->dbhost = 'localhost'; // assuming MS SQL is on the same server, otherwise use an IP
$CFG->dbname = 'moodle'; // or whatever you called the database you created
$CFG->dbuser = 'yourusername'; // I usually use the 'sa' account (dbowner perms are enough)
$CFG->dbpass = 'yourpassword';
$CFG->dbpersist = false;
$CFG->prefix = 'mdl_'; //Prefix, you can change it, but NEVER leave it blank.

If you don't have a config.php file yet, it can be generated as normal from the Moodle installer.


6. Restart or start your web server. If Moodle still cannot communicate with the database server, please turn display_startup_errors to "On" in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies. These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.


7. Database conection test, try this PHP script, just put in a text file called test.php change ('localhost', 'db_user', 'db_password') to suite your setup, and load from local host (http://localhost/test.php)...

<?php
$link = mssql_connect('localhost', 'db_user', 'db_password');
if(!$link) {
echo'Could not connect';
die('Could not connect: ' . mssql_error());
}
echo'Successful connection';
mssql_close($link);
?>

8. Install Moodle as usual. Good luck!

 
                                    
In reply to dung tran

Re: Moodle with IIS 6

by Octavian Brinzea -
I needed to install moodle on a new server.I use the same tutorial but if i try to install moodle pointing http://xxx.xxx.xxx.xxx/install.php i get the error

"The page cannot be displayed"

please help smile

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Kelli McCarter -

Octavian,

I have gotten to the same point in the installation and I am getting this error.  I have deleted my config.php file and started over and it will not go any further.  I'm stuck here.  I get the MSSQL section when I run phpinfo() and I get a "Successful connection" message when I run the test.php script so I think I have everything set up correctly.  I posted on another forum about this but haven't heard anything from anyone.  Can anyone help with this?

Kelli McCarter

In reply to Kelli McCarter

Re: Moodle with IIS 6

by Octavian Brinzea -
It seems we have an identical problem...maybe somebody who fixed this will help us.
In reply to Kelli McCarter

Re: Moodle with IIS 6

by Luis de Vasconcelos -

Before you deleted the config.php file did you check that you had set it up correctly?

The $CFG->wwwroot variable must contain the web address for your site, e.g.:

$CFG->wwwroot = 'http://yourdomain';
or
$CFG->wwwroot = 'http://yourdomain/moodle';
or
$CFG->wwwroot = 'http://localhost/moodle';

And $CFG->dirroot must contain the actual path where you extracted the Moodle archive to, e.g.:

$CFG->dirroot = 'C:\Moodle';

And $CFG->dataroot must contain the actual path to your MoodleData folder, e.g.:

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

What web server are you using? Apache or IIS?
Have you set it up for your Moodle website? E.g. did you create a virtual directory in IIS?

In reply to Luis de Vasconcelos

Re: Moodle with IIS 6

by Octavian Brinzea -

I managed to enter the installation of moodle.I've deleted the config.php from moodle directory and it worked....but i face this error now :

PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL. Please check your php.ini file or recompile PHP.

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by Octavian Brinzea -

I test the php connection with sql and this is what i get :

PHP Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'admin'. The user is not associated with a trusted SQL Server connection. (severity 14) in C:\moodle\test.php on line 1 PHP Warning: mssql_connect() [function.mssql-connect]: General SQL Server error: Check messages from the SQL Server (severity 14) in C:\moodle\test.php on line 1 PHP Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost in C:\moodle\test.php on line 1 PHP Fatal error: Call to undefined function mssql_error() in C:\moodle\test.php on line 1

In reply to Octavian Brinzea

Re: Moodle with IIS 6

by dung tran -
1.extract the moodle zip package in C:\moodle
2.in IIS, create alias moodle in virtual directory and browse to c:\moodle
3. so i think the link of the install.php is: http://xxx.xxx.xxx/moodle/install.php (if you setup php and mssql correctly)