Virtualising Moodle means using a single installed code base to operate an indeterminate number of Moodle platforms, standalone or configured in a network. The process stores the main configuration parameters (paths and database) of the virtual instances in the database (dynamically), and performs a very early switch of the service configuration from this registry.
The configuration switch is based on recognising the host name in the server's environment variables. The host name presented by the web server to the PHP runtime must match the host identity (virtual wwwroot) stored in the registry. As a result, the following use cases require specific precautions and implementations:
Standard Moodle CLI scripts are not compatible with virtualisation. Indeed, without a server environment defining the active domain name, standard CLI scripts are unable to perform the virtualisation resolution.
That is why the VMoodle implementation provides most of the standard CLI scripts adapted for virtualised use by adding a –host command line parameter making this resolution explicit:
php {cliscript} --{param1}={val1} --host=http://virtual.mymoodle.fr
VMoodle also provides a series of industrialisation scripts to massively carry out deployments and transformations of many Moodle units.
Industrialisation scripts allow massive distributed operations on all the tenants registered in the virtualisation.
Progress notifications: In recent versions, the industrialisation scripts send administrators a progress indicator. Other recipients can be designated by defining a key:
$CFG->techoperator = '<list of target emails>';
On the basis of this industrialised launch structure, other VMoodle-specific scripts are available in the /local/vmoodle/cli directory
VMoodle has a set of network super-administration commands to launch actions on all or part of the virtualised Moodle instances. These commands can be invoked from the VMoodle administration interface, but now also on the command line with the command:
php local/vmoodle/cli/run_command.php
The command will always run starting from the main instance (a super-administration command cannot be launched in a virtual instance). The command accepts 4 parameters:
tohostsmatch can be used with a simplified REGEXP pattern (* for .* and ? for .?) to select a set of instances by name filtering.Command example:
\$sudo -u www-data /usr/bin/php local/vmoodle/cli/run_command.php
--fromhost=http://source.virtual.moodle.org
--tohosts=http://target1.other.moodle.org,http://target2.other.moodle.org
--command=generic/CopyFilearea --attributes=fileareaid=mod_h5p%2Flibraries%3A0
You can check the list of targets of a command launch before actually launching it:
php run_command.php --command=showtargets [--fromhost=<fromwwwroot>] --tohostsmatch=<testedpattern>
The result of this command displays the list of virtual Moodles to which the command will be applied.
Using the additional configuration key:
$CFG->vmoodleusesubpath = true;
enables the 'subdirectories' configuration of VMoodle. All the virtual instances will then be operated as a first-level subdirectory of a single domain root:
https://my.vmoodle.org/moodle1 https://my.vmoodle.org/moodle2 https://my.vmoodle.org/moodle3 ...
The advantage of this model is the saving in HTTPS certificates (a single domain certificate for all instances). It may however cause some confusion in the memorisation of data entered on the web client side.
The instance name is automatically captured from the subdirectory name.
Setting up virtualised Moodles at a lower level of the tree is not supported.
To set up this type, you will need to set up instance symbolic links in Moodle's code installation directory:
drwxrwsr-x 11 root root admin drwxrwsr-x 24 root root auth drwxrwsr-x 6 root root availability drwxrwsr-x 7 root root backup drwxrwsr-x 6 root root badges -rw-rwSr-- 1 root root behat.yml.dist drwxrwsr-x 70 root root blocks drwxrwsr-x 3 root root blog -rw-rwSr-- 1 root root brokenfile.php drwxrwsr-x 6 root root cache drwxrwsr-x 6 root root calendar drwxrwsr-x 4 root root cohort drwxrwsr-x 4 root root comment drwxrwsr-x 4 root root competency drwxrwsr-x 5 root root completion ... lrwxrwxrwx 1 root root moodle1 => . lrwxrwxrwx 1 root root moodle2 => . lrwxrwxrwx 1 root root moodle3 => . ...
This setup ensures that each virtualised Moodle in a subdirectory has the Moodle source code available. The instance management tooling handles the setup of these symbolic links on behalf of the Moodle administrator through a local sudo procedure. The VMoodle configuration must designate a sudo user able to manipulate Moodle's installation directory, from the user running the server (apache, httpd, nginx, or other depending on the environment).
Back to the component index - Back to plugins index - Back to catalogue