Setup Multi instance codebase

October 7, 2008 – 16:08

For client setup a multi instance Moodle running on one codebase.

Quite straightforward. Things to focus on are config.php and the cron

Apache Virtual Host setup

I like the way ubuntu and debian setup their httpd.conf in sites-available and sites-enables dirs. I copied that way to our CentOS machines.

Created two new directories in /etc/httpd/conf/:

sites-available: each virtual host has it’s own config file in here named subdomain_domain_xx.conf

sites-enabled: the main httpd.conf includes all files in this directory. So if you want to enable a site, create a symlink here to the conf file i sites-available. The Moodle cron will read this directory and use the filenames to send the proper headers to the config.php / cron.php

If you want to add a new instance, simply copy the one of the existing confs and edit the Server and log names.

Added NameVirtualHost *:80 to httpd.conf just before Includes of sites-enabled to allow for name based virtual hosts

Postgres Database setup

I simply setup X Postgres databases naming them conveniently  name1,name2,name3,name4 etc.

Filesystem setup

Like for the database, I simply setup dirs in /var/moodledata/name1 /var/moodledata/name2 etc

Moodle config setup

In the Moodle config, I included a big array with associative arrays holding the config settings. The array is indexed with the referrer so the proper config object is selected. Config object then sets all the options in the actual config.php code. And it’s working! Great.

Cron setup

made cli command to run multiple crons based on conf files in /etc/httpd/conf/sites-enabled.

/bin/ls /etc/httpd/conf/sites-enabled/*.conf | grep -v stoas | /usr/bin/xargs -iNAME basename NAME .conf | sed s/_/./g | /usr/bin/xargs -iVHOST /bin/bash -c “HTTP_HOST=VHOST /usr/bin/php /usr/local/moodle/codebase/admin/cron.php”

Sorry, comments for this entry are closed at this time.