Can multiple instances of moodle use the same Moodledata files?

Can multiple instances of moodle use the same Moodledata files?

by nathaniel perkins -
Number of replies: 14

Can multiple instances of moodle use the same Moodledata files or use the same Cpanle server?

We have four different stores that we need to keep separated. I would like to make four different folders off of the Public-HTMS side of the server copy the current moodle files to the new folders. First, would the four new instances of moodle communicate with the moodledata files on the root? And second, if that would work how would I set up the SQL Database info? 

Or, am I even on the right track? Should I taking a different rout? If so, What would be the best way to do this thang? 

Moodle 2.9.2+ (Build: 20151028)

Thank you, Nate  

Average of ratings: -
In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Colin Fraser -

Yes, this is relatively simple, but is exacting. Get it wrong and it goes haywire spectacularly. Using the config.php file in the Moodle root, ther eis a setting that looks something like:

$CFG->dataroot  = 'http:\\yoursite\path\to\moodledata'; 

Aim that to the common moodledata directory and that will allow you to use the same moodledata directory.You can do the same with the database as well. You can adapt the following settings to what you need. 

$CFG->dbtype    = 'pgsql';      // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'

$CFG->dblibrary = 'native';     // 'native' only at the moment

$CFG->dbhost    = '192.168.1.110';  // eg 'localhost' or 'db.isp.com' or IP

$CFG->dbname    = 'thismoodle';     // database name, eg moodle

$CFG->dbuser    = 'admin';   // your database username

$CFG->dbpass    = 'password';   // your database password

Set one up then copy that config.php file to whatever location you need it. Tweak it where needed, but if the addresses are all absolute, it shouldn't need much. 


In reply to Colin Fraser

Re: Can multiple instances of moodle use the same Moodledata files?

by nathaniel perkins -

Colin, Do I need to make 4 new sql databases or should I use the original sql info?

Thanks for the quick response!


In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Usman Asar -
You can have (in fact should) have 4 different SQL's as database interacts with the dataroot as well, but it's database that keeps settings and courses intact.
keeping one dataroot and SQL will keep look consistent across all moodles.
In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Jamie Kramer -

I think you will have very bad, unexpected, and unknowable results if you use the same dataroot for multiple different Moodle sites. Each Moodle site would try to makes changes to the dataroot files, breaking the other Moodle sites, and corrupting the status of Moodle's internal file repository. 

Maybe I am mis-understanding you though. You say you want to use the same Moodledata files, which leads me to believe you are talking about the path defined in "dataroot" described above. If this is what you are talking about (as opposed to just the Moodle code) then this is not something you will want to do.


Jamie

In reply to Jamie Kramer

Re: Can multiple instances of moodle use the same Moodledata files?

by nathaniel perkins -

Ok, then is it possible to setup multiple instants of Moodle on one server? 

In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Jamie Kramer -

Yes you can have multiple instances on the same server. How you would go about doing this is going to very widely. From a high level, if you want 4 instances of Moodle on the same server, you would need:

* 4 different vhosts in the web server configuration, recommended... (unless you choose to host each moodle site in a sub directory). For example:

http://example.com/moodle1

http://example.com/moodle2

I do not recommend using the sub-directory for the different Moodle sites, as it can complicate moving individual sites later if you ever need to migrate the site.


4 different wwwroot folders/directories for each site

4 different config.php in each wwwroot

4 different databases (or you can use the same database with different table prefix  for each site in config.php, though maybe better to have separate/different db for each site)

4 different dataroot directories/folders, one for each site

If you are using SSL, you may need 4 different SSL certificates (unless you use a special certificate such as a wildcard certificate or a UCC/multiple-domain certificate). Also if you were to host each moodle site in a sub-directory/sub-folder of the main vhost, then one SSL would suffice, though I don't recommend it (see point above about Moodle in sub-directory)

4 Different DNS records, one to point to each site (again, assumes you don't take the sub-directory/sub-folder path)


I know that is a lot and I hope it makes sense.

Jamie

In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Usman Asar -

Doubling on Jamie's comments, you can end up in trouble, yes this can happen.

and yes you can have as many instanes of moodle on one server as you can, keeping dataroot and SQL seperate for every moodle (an ideal scenario). BUT, make sure your hosting can handle that many instances of Moodle, as moodle is not wordpress with 12-14 tables that gets installed during installation, its 300+ tables that comes as a part of Moodle installation, and that really effects database I/O's, this is the reason some hosting companies do limit the number of tables in the shared SQL database to 1000, means you can have upto maximum 3 on one hosting account.

Average of ratings: Useful (1)
In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Nathaniel, to get a feel for this database stuff, many cPanels provide a tool called "MySQL Databases."  If you have this, click on it and you will begin to understand the databases on your server.  At this point, my guess is that you should see at least one shown, for your moodle.  It is pretty safe to experiment with this tool by adding a new database, adding a user, then deleting this database.  Do this a couple time to start appreciating the concept of adding database.  DO NOT DELETE your current moodle database.

Yes, no problem with multiple installs of moodle on a server, given that your hosting company permits this (as Usman said.)  I have done this.  But as suggest, develop a scheme for the installations that won't drive you crazy remembering what goes where.  So for your second moodle, use something like .../moodle2 for moodle, moodle2db for the database, and moodledata2 for the moodledata folder.  Having said this, you should be able to tell us what your third installation should look like.

Attachment cpanel.jpg
In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Ron Meske -


Nate,

It is clear you have 4 separate stores and you want to keep them separate.  What isn't clear is how Moodle is being used by each store.  Do you have one Moodle Admin that handles all courses and user accounts? 

If so, you could make use of some of the built in features of Moodle to manually enroll users into courses using groups to keep them separate.  We have been using this type of technique since Moodle 1.9 for a client and it works quite well.  In the newer versions of Moodle there are some additional ways of accomplishing the same thing.

If not, and each Store will be managing their own users and courses, it is best to use separate databases and moodle dataroot folders.  You could possibly use one database and make use of the feature of setting a unique prefex for each store that will create it's own set of tables in the database.  The downside to this approach, from my understanding, is performance of the database.

The approach's that have been discussed in these forums and used for multi-tenancy are:

  1. You can create four different installs on one server as long as you setup virtual hosts for each store so the web server knows which site to load.  The downside is you have four different moodle installs to update and more space requirements.
  2. I can't find the forum post right now, but someone spelled out how to use one install of Moodle and make use of some dynamic code in the config.php file that would look at the URL and automatically set the database and moodle wwwroot and dataroot locations.  The downside is that you have only one version of the database for all instances which at some point might not be ideal if there is a pluing that one instance uses and isn't compatible with the new version.

In terms of performance, I am not sure which approach will give you the best performance.  If anyone knows, I would like to hear about it.

 

Ron

 

Average of ratings: Useful (1)
In reply to Ron Meske

Re: Can multiple instances of moodle use the same Moodledata files?

by nathaniel perkins -

In my situation, I will have 4 different admin users and I need to keep all the user data separate. 


In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Ron Meske -

I located the conversation I had mentioned previously on how to setup multiple Moodle instances with a single Moodle code install.  

Run multiple instances of Moodle without duplicating base code?

You should also make sure your setup includes enough memory to support memory caching of 4 different sites.


In reply to Ron Meske

Re: Can multiple instances of moodle use the same Moodledata files?

by nathaniel perkins -

Thank You Ron!

In reply to nathaniel perkins

Re: Can multiple instances of moodle use the same Moodledata files?

by Colin Fraser -

People have been running multiple instances of their Moodle for years, using single moodledata roots, but there are some conventions I would think. If a single database is required, I would think it be obvious that no two courses have the same name or same short name. Each instance of the codebase uses different prefixes for their cookies, clearly, even if some users use more than one Moodle at the same time, or not. Personally though, I wouldn't use a single database, but it can be done. All I am suggesting is it can be done, but be mindful that there are traps that can make the whole thing a lot of work to maintain. I cannot see the point of using a single moodledata root and different databases though.