Any tips on easily configuring multiple Moodles

Any tips on easily configuring multiple Moodles

by Ian Usher -
Number of replies: 4

[with apologies if this 'fits' somewhere else...]

thoughtful Here's my plan:

  • we have 200+ schools
  • I'm planning on offering each one their own Moodle, aliased to something like learning.schoolname.bucks.sch.uk
  • Each school should be able to configure its own instance of Moodle to its heart's content (colour, CSS, language, other bits that I'll decide later etc.)

however, I'd like the back-end management process of this to be as simple as possible, i.e. I want any version upgrades to be simple for our host (who are supporting us in implementing Moodle, but it's their first time of doing so...).

The servers are IIS (sorry) with MySQL & PHP (obviously).

mixed Has anyone done something similar who could offer tips of the Do this but don't do this! variety? If anything's not clear then please ask & I'll clarify.

Average of ratings: -
In reply to Ian Usher

Re: Any tips on easily configuring multiple Moodles

by W Page -
Hi!

See the following,

This post,
http://moodle.org/mod/forum/discuss.php?d=10658&parent=51719
On this thread.
Re: Multiple Moodles, One Database
http://moodle.org/mod/forum/discuss.php?d=10658

AND

This thread
How can I install several Moodles using one database??
http://moodle.org/mod/forum/discuss.php?d=9320

I am sure some of the experienced folk will have more to say about it.

BTW, you  may want to ask Martin to move this thread into the Servers and Performance Forum.

WP1



In reply to Ian Usher

Re: Any tips on easily configuring multiple Moodles

by Martín Langhoff -
As part of the NZVLE project (https://eduforge.org/projects/nzvle/) we are running a demo server with many moodle instances running off the same code, with a slightly "tricked" config file.

We are moving to a production server soon, where the moodle instances will be split in two: those that run off a single codebase, as it is now on the demo server, and those that need a special version of the code, and thus have a different setup and configuration.

The demo server is running each moodle instance with a virtualhost with a special name that is on the left of the root name: instance "foo" will be hosted in foo.lms.eduforge.nz. We use that unique part to magically define the table prefix (thus hosting all of them in the same database table) and the data directory.

To add a new instance, say 'bar' we just add a data directory and a virtualhost to Apache (in fact, we add a ServerAlias line to the virtualhost entry). You would have to add a virtualhost to IIS.

You can easily adapt this technique to different domains, or to different subdirectories/aliases. The trickery is achieved by adding tha few bits and pieces to config.php:

= I've added this at the top:

<?PHP // $Id: config-dist.php,v 1.54 2004/05/03 14:57:11 moodler Exp $

/// EDUFORGE MOODLE LMS SETUP --- YOUR ATTENTION PLEASE!!!!
///
/// This config file supports many moodle instances from one directory
/// and one config file.
///
/// We'll get the virtualhost prefix (foo in foo.lms.eduforge.org) and use that
/// to define:
/// - DB table prefix
/// - VAR directory: /home/lms/var/$prefix/
/// - Optional config override file: you can override any config value by creating
///  a config_$prefix.php file. Be cautious, however!

// Obtain and sanitize prefix
$eduforge_prefix = $_SERVER['HTTP_HOST'];
if (isset($_ENV['HTTP_HOST'])){ // this is to support cronjobs on a per-host basis
        $eduforge_prefix = $_ENV['HTTP_HOST'];
}
$eduforge_prefix = explode('.', $eduforge_prefix);
$eduforge_prefix = $eduforge_prefix[0];
$eduforge_prefix = preg_replace("/\W/", "", $eduforge_prefix);

// if there wasn't a prefix redirect to eduforge
if($eduforge_prefix == 'lms' || $eduforge_prefix=='') { //
        header("Location: http://eduforge.org/");
        exit;
}


== And then later, we modify other lines:

$CFG->prefix    = $eduforge_prefix . '_';        // Prefix to use for all table names
$CFG->wwwroot  = 'http://' . $eduforge_prefix . '.lms.eduforge.org';

$CFG->dataroot  = '/home/lms/var/' . $eduforge_prefix;

== And a bit before the end, just before the error checking stuff, we add this to allow a completely different config:

// Allow file overrides for eduforge
if (file_exists("$CFG->dirroot/config_" . $eduforge_prefix . ".php"))  {      // Do not edit
        include_once("$CFG->dirroot/config_" . $eduforge_prefix . ".php");
}

=== END

Hope this helps. I can send you a unified diff if it helps.

regards,







martin
In reply to Martín Langhoff

Re: Any tips on easily configuring multiple Moodles

by Mawuli Kuivi -
Hello Martin,
This looks like some l can use for my setup.

Which version of Moodle are you running this setup with?

How would l go about setting things up if l have two domains
dc1.cp.hostname
lms.pc.localhost

How would l go about getting this setup to have both instance run from the same code base?

M.


In reply to Mawuli Kuivi

Re: Any tips on easily configuring multiple Moodles

by Martín Langhoff -
Moodle 1.4.4+. Also works with Moodle 1.5dev.

Read the thread carefully -- it manages different domains on one codebase. You'll have to tweak it a bit (requires some PHP knowledge) and also tweak your Apache config.