Skip to content

How to create a Moodle instance and join it to your ViSH instance

Enrique Barra Arias edited this page Jul 7, 2017 · 11 revisions

The steps are easy to follow, you need a Moodle instance and if you already have one, go to step 2 directly. Steps:

  1. Install Moodle
    1. Steps
    2. Initial Moodle configuration
    3. Setting up a style/theme
  2. Join your Moodle instance to ViSH and enable courses
  3. Set up CAS to allow single sign on and out
    1. CAS Server
    2. Configure Moodle to sign in with CAS

To install Moodle we have used a server with:

  • Ubuntu 16.04 server 64bits (also works with previous editions)
  • 2GB RAM (this will depend on the number of concurrent users you expect
  • 2GHz dual core

Follow the official installation guide, depending on the version of Moodle you want to install.
We recommend Moodle 2.9 https://docs.moodle.org/29/en/Installing_Moodle

This section presents the steps that we had to apply following the official instalation guide.
The instalation guide gives a lot of options for the server software (apache, Nginx, IIS, ...). We have chosen Apache2, postgresql, php.
These are the commands to install this software in Ubuntu 16.04 server:

sudo apt-get update
sudo apt-get install apache2 php postgresql postgresql-contrib
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install libapache2-mod-php5.6 php5.6-pgsql php5.6-gd php5.6-curl graphviz aspell php5.6-pspell php5.6-intl php5.6-xmlrpc php5.6-ldap php5.6-zip php5.6-xml php5.6-soap php5.6-mbstring

Edit php.ini (usually located at /etc/php/7.0/apache2/php.ini), and change the following:

post_max_size = 20M
upload_max_filesize = 20M

At this point you should be able to see the apache default page if you go with a browser to the IP or hostname of your server.

Download moodle from https://download.moodle.org/releases/latest/ or https://download.moodle.org/releases/supported/
Copy the downloaded moodle package to your server, so form your local machine exec something like (command will vary depending on your Moodle version and server IP):

scp moodle-latest-33.tgz root@YOURSERVERIP:.

In your server uncompress the package. This will create a "moodle" directory:

tar -xvzf moodle-latest-33.tgz

Now it is time to configure postgres

sudo -u postgres psql postgres
\password postgres
Enter new password: ENTER_YOUR_PASSWORD

CREATE USER moodleuser WITH PASSWORD 'yourpassword';
CREATE DATABASE moodle WITH OWNER moodleuser;

Now create the moodledata directory:

mkdir /path/to/moodledata
chmod 0777 /path/to/moodledata

Finally start Moodle instalation:

cd /path/to/moodle
sudo chown www-data .
cd admin/cli
sudo -u www-data /usr/bin/php install.php

In this last command you will be asked a lot of questions, most of them you only have to hit enter, except for the database configuration, postgres uses port 5432, choose localhost for the database server. User and password the one you have chosen (usually moodleuser and your password).

And prepare the files with the adequate permissions:

cd /path/to/moodle
sudo chown -R root .
sudo chmod -R 0755 .
sudo find . -type f -exec chmod 0644 {} \;
sudo chown -R www-data mod
sudo chmod -R u+w mod
sudo chown -R www-data theme
sudo chmod -R u+w theme

If your apache server will only be serving this moodle site you can remove the apache default file /var/www/index.html and move your moodle folder content to /var/www if you are in an apache server that server multiple pages, you will have to add a new virtual host (help)

At this point you should be able to see your moodle default home page if you visit http://YOURSERVERIP

Moodle has a lot of options to configure. You can read a lot of documentation at http://moodle.org to properly customize your site.
For example you will have to choose a theme or install one. We recommend the essential theme that is based in Bootstrap Link

In this section we expose the minimum configuration to start working with your Moodle instance.

  • Administration > Site administration > Plugins > Message Outputs > Email: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page.

  • Administration > Site administration > Server > HTTP: If you are behind a firewall you may need to set your proxy credentials in the 'Web proxy' section.

  • Administration > Site administration > Location > Update timezones: Run this to make sure your timezone information is up to date. (more info Location)

  • Configure Cron: Moodle's background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the Cron instructions.

  • Check mail works: Create a test user with a valid email address and send them a message. Do they receive an email copy of the message? If not, check the settings in Settings > Site administration > Plugins > Message outputs > Email. Don't be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)

For the style of your site you can use any theme that you like. We recommend using essential theme for Moodle 2.9 as it is open source and you can set up it. Important, remember to use the BRANCH MOODLE_29 Even you can modify it by forking as we did: https://github.com/ging/moodle-theme_essential If you fork and modify the theme essential, remember that if you change any less file you have to exec "grunt compile -build=p" and upload the result to see the changes in your Moodle instance

To join a Moodle instance to your ViSH instance you will have to properly configure your application_config.yml.
For this you have to add "Course" to models[available] And add the option moodle_url with the URL of your moodle instance.

If you need extra help please read this page You can see an example of configuration of this file in application_config.yml.example in the repository

If you want your users to sign on your Moodle instance with the same username and password than in your ViSH instance you need a CAS server.

The first step is to set up a CAS server. For this purpose we have used http://casino.rbcas.com/ but you can use any other compatible CAS server. In our case, this cas server uses directly the ViSH database to access user and password (really we are using a SQL VIEW for this table). This is because we already had registered users, but if you are just starting your instance, the CAS server can use its own database and ViSH can be enhanced to support CAS protocol.

The second step is to set up your Moodle instance. The Moodle instance comes with CAS loggin support but user attributes are only captured if this CAS is done through LDAP. In our case we are doing it through CAS directly and so we need an extra plugin to get the user attributes and skip a initial user config screen where the user has to enter his/her same data again and can make mistakes and have problems. For that we are using this plugin https://github.com/middlebury/Moodle-auth_casattras To install the plugin follow the instructions at the github page and after that in the route Site Administration -> Plugins -> Authentication -> CAS server (SSO) with user-attribute release you can configure the CAS access with the following data:

Param Value
hostname http://cas_server_domain.com
Base URI cas/cas
port 443
Cas protocol 2.0
Proxy mode no
Logout option yes
Multiautentication yes #change to no when everything is working, but in a first step keep yes to be able to login as admin to set up CAS again
Server validation no
Certificate path URL of your server certificate
Alternative logout return URL url to return when logging out

Data mapping:

Data Value
name name
surname surname
email email