Multiple versions of Moodle4Mac on one computer?

Multiple versions of Moodle4Mac on one computer?

by Lorin Toews -
Number of replies: 11

I'm developing Moodle plug-ins for multiple clients who are running different versions of Moodle (2.7 and 2.9). I would like to be able to test my plug-ins on the same versions of Moodle that they have, so it would be very useful to have multiple versions of Moodle4Mac running on my computer. 

Putting moodle27 and moodle29 into the same htdocs folder didn't work.

Creating separate partitions for each Moodle version didn't work because it seems that MAMP will only run from the Applications folder on the startup drive.

Creating virtual hosts seems like it should work, but I spent a lot of time trying to do that manually with no success.

I'm prepared to upgrade to MAMP Pro and let it manage virtual hosts for me, but I'm concerned that Moodle4Mac might be hard-coded to run on the free MAMP.

I've searched these forums and the Internet, and I haven't found anything useful.

Has anyone been able to make this work?

Average of ratings: -
In reply to Lorin Toews

Re: Multiple versions of Moodle4Mac on one computer?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you are using MAMP, you don't need Moodle4Mac.  Just download the basic moodle code and save to a folder (moodle27 and moodle29 e.g), in MAMP reference them as new hosts and you are good to go.  I highly recommend MAMP pro - use it myself and run a couple of development Moodle sites, along with Wordpress sites etc...

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: Multiple versions of Moodle4Mac on one computer?

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

I second what Emma is saying.  I have 5 versions of Moodle on my MAMP, and it works real well for experimenting.  Fast, and always available (without the need for an Internet connection.)  Also, how I interact with MAMP is very similar to how I interact with my VPS, so it is a really great learning environment.  XAMP is pretty good too, but I find MAMP (because I am a Mac guy) easier.

In reply to Lorin Toews

Re: Multiple versions of Moodle4Mac on one computer?

by Ken Task -
Picture of Particularly helpful Moodlers

First a question ... do your clients run their Moodles on Mac's?  IF not, what do they use?   Think it a better approach for development that the development system be as close to the production environment as possible - there are some small but could be significant differences when developing a plugin .... but that's just me, I guess.

While Rick and Emma has said yes it's possible, they didn't seem to mention how!!!

Now am a command line person myself, but one could translate most of the commands below into GUI usage.   And Rick/Emma might have an easier way .... So here goes:

Use the MAMP.app panel to launch it ... start Apache and MySQL servers.

After you get MAMP installed and running with the version 2.8
check the page at: http://localhost:8888/MAMP/index.php?language=English

Using PHPMyAdmin create a database for moodle29
Character set utf8 collate utf8_general_ci

In /Applications/MAMP/data
create a data directory for moodle29
cd /Applications/MAMP/data/
mkdir moodle29

Install git

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

or acquire the 29 code zip and download.  Unzip into the moodle29 directory you created.
All the code files should be at the root of the moodle29 directory/folder.

Using git
cd /Applications/MAMP/htdocs

Then issue the following git commands:

git clone -b MOODLE_29_STABLE git://git.moodle.org/moodle.git moodle29
cd moodle29

To check that you have the right version:
fgrep '$release' version.php

Copy the config-dist.php file to config.php

Edit config.php

$CFG->dbtype    = 'mysqli';      // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native';     // 'native' only at the moment
$CFG->dbhost    = 'localhost';  // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname    = 'moodle29';     // database name, eg moodle
$CFG->dbuser    = 'moodle';   // your database username
$CFG->dbpass    = 'moodle';   // your database password
$CFG->prefix    = 'mdl29_';       // prefix to use for all table names
$CFG->dboptions = array(
    'dbpersist' => 0,       // should persistent database connections be
                                //  used? set to 'false' for the most stable
                                //  setting, 'true' can improve performance
                                //  sometimes
    'dbsocket'  => 1,       // should connection via UNIX socket be used?
                                //  if you set it to 'true' or custom path
                                //  here set dbhost to 'localhost',
                                //  (please note mysql is always using socket
                                //  if dbhost is 'localhost' - if you need
                                //  local port connection use '127.0.0.1')
    'dbport'    => '',          // the TCP port number to use when connecting
                                //  to the server. keep empty string for the
                                //  default port
);

$CFG->wwwroot   = 'http://localhost:8888/moodle29';
$CFG->dataroot  = '/Applications/MAMP/data/moodle29';

** hide the index.php file in /Applications/MAMP/htdocs (that file sets the header to go to moodle28 ... we don't want that)
from /Applications/MAMP/htdocs/
mv index.php .index.php (see the 'dot' in front of index.php?  That hides index.php and apache will not use.
The result of that, when one uses browser to go to http://localhost:8888/ one will now see a raw directory listing that looks like:

moodle
moodle28
moodle29

It's oK with a development box to have a raw directory listing.   NOT on production server however.

Now go to http://localhost:8888/moodle29/ by clicking on the moodle29 directory.

You are now in the installation mode.

NOTE: advantage in using git ... easily updated (git pull) and upgraded (a few more commands but that's for later when 3.0 has been released)

'spirit of sharing', Ken


In reply to Ken Task

Re: Multiple versions of Moodle4Mac on one computer?

by Ken Task -
Picture of Particularly helpful Moodlers

Just one addition ... as a development machine, it would be nice to be able to use the Moodle UI to install/update plugins/addons, thus a cert needs to be added to the data folder for the moodle29 (as well as the original moodle28):

cd /Applications/MAMP/data/moodle29/
curl -O http://curl.haxx.se/ca/cacert.pem
mv cacert.pem moodleorgca.crt

Now you shouldn't have any issues with SSL/https and the ability
to install/update plugins via the Moodle Admin UI.

'spirit of sharing', Ken




In reply to Ken Task

Re: Multiple versions of Moodle4Mac on one computer?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Actually, if you are just using it for development and not accessing from the outside world, a cert is not needed.

When I set up in MAMP, this is my process:

1. Download moodle code.  Unzip folder to location where I keep all my development sites.  I tend to rename to latest release (e.g moodle29).

2.  Create a moodledata folder (I also name this to release - eg moodle29data)

3.  Open MAMP.

4. Click on Add Host.  Select location of moodle29 (moodle code) folder.

5. Restart servers in MAMP.

6.  Go to webpage of newly created moodle (moodle29:8888 in my case).  You can create the database during the install process.

7.  Install as normal.

No, I don't use git which I know has lots of advantages but I had issues the first time I tried it and haven't had time to try it again and I don't find it that hard to upgrade manually.

Using it as just a local site, it still has access to plugin install through gui.

In reply to Emma Richardson

Re: Multiple versions of Moodle4Mac on one computer?

by Ken Task -
Picture of Particularly helpful Moodlers

Hmmmm ... some differences ... you must be using the Pro version.   In the freebie, no such thing as 'Add Host'. sad   Your description is much easier for sure.

About cert ... not for running the site as https but for installing addons/plugins, etc. via Moodle UI - it might be needed.

About git ... easy install on a Mac.   Plus, in the MAMP directory there is a UpdateMoodle28.sh script which uses git.

See ... that's my problem ... tend to think command line first!  That's probably cause I started with MSDOS machines prior to anything graphical! :\

'spirit of sharing', Ken


In reply to Ken Task

Re: Multiple versions of Moodle4Mac on one computer?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I do use the Pro version - very simple - have a new site up in less than five mins!

Still do not need the cert to install plugins via Moodle gui. 

Good to know about the script - I will try again sometime - just gets complicated if there are a lot of addins, I have found. 

I learned command line just so I could install Moodle on a Linux several years ago! So I pretty much just know what I need to know for the few things I run on Linux!  Last time I tried git I ended up with the wrong version and made a big old mess!!  Just haven't had the energy to try it again but know that I should!

In reply to Ken Task

Re: Multiple versions of Moodle4Mac on one computer?

by Lorin Toews -

Ken,

I'm amazed at the detail you provided for a command line solution to my situation. I hope some other struggling soul finds your post and realizes it's exactly what they were looking for. 

I also go back to the days of MSDOS, and I miss the (relative) simplicity of the command line. Successfully crafting your own startup menu using just CONFIG.SYS and AUTOEXEC.BAT was enormously gratifying.

In reply to Lorin Toews

Re: Multiple versions of Moodle4Mac on one computer?

by Lorin Toews -

Emma, Rick, and Ken:

Thanks for all the advice, especially the detailed instructions. I will poke around with your suggestions and report back.

In reply to Lorin Toews

Re: Multiple versions of Moodle4Mac on one computer?

by Lorin Toews -

Emma,

Thanks for the suggestion to go with MAMP Pro. It was as easy to set up as you described.

In reply to Lorin Toews

Re: Multiple versions of Moodle4Mac on one computer?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Yes, that is one software definitely worth paying for!!