Skip to content

Instantly share code, notes, and snippets.

@bacalj
Last active February 8, 2024 20:24
Show Gist options
  • Select an option

  • Save bacalj/d1782a7f87472483cdb4463e6a1ee182 to your computer and use it in GitHub Desktop.

Select an option

Save bacalj/d1782a7f87472483cdb4463e6a1ee182 to your computer and use it in GitHub Desktop.
Getting a local Moodle running with Lando

Run Moodle Locally with Lando

Moodle: https://moodle.org/ Lando: https://docs.devwithlando.io/ Docker: https://docs.docker.com/


  1. Run docker on your machine. I use the "Docker for Mac" desktop app.

  2. Get lando running on your machine. Follow these directions. It's pretty quick. https://docs.devwithlando.io/installation/installing.html

  3. Set up a moodledata directory somewhere you can find it. You will need to know its location relative to your home directory on your machine, as later we'll have to tell the docker image where to find it in its docker world.

$ cd /Users/jebacal/landolanding/
$ mkdir mynewlandomoodle
$ cd mynewlandomoodle
$ mkdir moodledata
  1. Now - to get Moodle to be able to write into the moodledata directory at the start of things, you have to do this. We'll change it back later.
$ chmod -R 0777 moodledata
  1. Now go to wherever you like to have your local moodle codebases. I keep mine under sites/moodles. Make a new Moodle. I'm using CLAMP Moodle.
$ cd sites/moodles
$ mkdir mynewlandomoodle
$ cd mynewlandomoodle
$ git clone https://github.com/CLAMP-IT/moodle.git
$ cd moodle
  1. Maybe you want to check out a certain branch. Go ahead. Now its time to get a lando file in here. If you want to just get something running and all the latest and greatest versions are good for you, then just do this.
$ lando init

and then go to #7.

Otherwise, If you need to mess with the recipe, then go to #6.5

6.5 Going to try just putting in a customized recipe lando file without running lando init. In my case I need to run a version of Moodle that does not like PHP 7.1 so I will try this :

# inside /moodle
$ touch .lando.yml

and then put this in that file:

name: threeone
recipe: lamp
config:
  webroot: .
  php: '5.6'

and then try lando start and then lando info

  1. Now you have a fun chance to choose a preset Lando recipe. Arrow down and choose LAMP. Now things will happen by magic.
$ lando start
$ lando info
  1. Collect this information. You will need it soon.

  2. Visit the link that looks like http://mynewlandomoodle.lndo.site:8000

  3. Moodle wants some info to start up the installation. The one you need to change is the data directory. It should be the one you created way up at the top but under /data. This is all about matching a location in the docker container. So in this case it would be: /user/landolanding/mynewlandomoodle/moodledata

  4. Click through until it is time to add your database credentials. The stuff you need is in the output of lando info. In this case it is:

  • Database host: database.mynewlandomoodle.internal
  • user: lamp
  • database: lamp
  • password: lamp
  1. It's all clicking from here. Your local Moodle should be running.

  2. Need some other php extensions? MariaDB? Different credentials? Other stuff? Your .lando.yml file can be leveraged to do all kinds of amazing things that I don't even know the half of. Read about it here: https://docs.devwithlando.io/started.html

  3. Go back and fix permissions on that moodledata directory

$ cd /Users/jebacal/landolanding/mynewlandomoodle
$ chmod -R 0770 moodledata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment