User Tools

Site Tools


computing:moodle

This is an old revision of the document!



  • moodle
  • Jonathan Haack
  • Haack's Networking
  • netcmnd@jonathanhaack.com

Installing moodle on a Debian system.


The pre-requisites:

  • Using Debian or similar
  • Self Hosted Web Server using Apache 2.4
  • Available Domain with DNS set up
  • Self-Signed Certificate is established as backup
  • Letsencrypt, using certbot, is established and working

If you are missing some of these pre-requisites, please visit the Apache Survival Tutorial I created which covers these topics. Ok, now that you have all that ready, let's install some php extensions and some other dependencies of Moodle.

sudo apt-get install aspell graphviz php7.0-curl php7.0-gd php7.0-intl php7.0-ldap php7.0-mysql php7.0-pspell php7.0-xml php7.0-xmlrpc php7.0-zip php7.0-soap php7.0-mbstring

There is a Digital Ocean Tutorial for Moodle that I used as a jumping off point, but it omits two php packages that are recommended and which I included above. Next, let's download Moodle and move it to our DocumentRoot for our preferred VirtualHost:

curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz
sudo tar -xvzf moodle.tgz -C /var/www/domain.com/public_html/

Now that you have installed the moodle directory into your Web Server's VirtualHost directory, you are ready to set up the Moodle Data directory, which should be outside of the root of the Web Server. Additionally, change the ownership to the www-data user that Apache uses and give the owner and admin group full permissions as follows:

sudo mkdir -p /var/www/domain.com/moodledata
sudo chown -R www-data /var/www/domain.com/moodledata
sudo chmod 0770 /var/www/domain.com/moodledata

If you visted the site and tutorial I shared, you may notice that it some database configurations for Ubuntu that are not required for stock Debian. As long as you followed the steps for setting up the LAMP stack that I outlined in the Apache Survival tutorial, you should be able to omit these steps and proceed to setting up the database. Change the underlined parts below:

sudo mysql -u root -p
CREATE DATABASE __nameofdatabase__ DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 
create user '__usernameofdatabase__'@'localhost' IDENTIFIED BY '__passwordfordatabaseuser__';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON __nameofdatabase__.* TO '__usernameofdatabase__'@'localhost' IDENTIFIED BY '__passwordfordatabaseuser__';
quit;

Now the database is set up, so let's restart the mysql service and while we are at it, let's restart apache2 for good measure:

sudo systemctl restart apache2
sudo systemctl restart mysql

Now we need to temporarily make the Moodle server world writeable so that we can configure it from our web browser:

sudo chmod -R 777 /var/www/domain.com/public_html/moodle

After this, use your web browser of choice and navigate to domain.com/moodle/ and go through the configuration steps. You will need to specify the usernameofdatabase and the passwordfordatabaseuser you specified above. Also, pay special attention to the Moodle Data directory and ensure that it populated correctly - sometimes it specifies the wrong directory. Lastly, on Debian you will encounter an error in the php.config that needs to be resolved. This glitch is covered on Moodle.net Forums and thanks to Marina for identifying that annoying, yet easy to fix, configuration error!

cd /var/www/domain.com/public_html/moodle/
sudo nano php.config

In the first five lines, the configuration specifies “mysqli” and this needs to be changed to “mariadb” instead. Once this is done, you should be able to complete the installation options given on the web page. It is now time to set up Moodle and use the Learning Management System for what it is designed for - learning with FreeSoftware! Here is a Moodle Tutorial I found helpful. Now that we are done with the tutorial, take a look at my finished product haackslms.

Moodle recommends the following directory hardening measures:

1. moodledata directory and all of its contents (and subdirectories, includes sessions):

owner: apache user (apache, httpd, www-data, whatever; see above) group: apache group (apache, httpd, www-data, whatever; see above) permissions: 700 on directories, 600 on files

2. moodle directory and all of its contents and subdirectories (including config.php):

owner: root group: root permissions: 755 on directories, 644 on files.

If you allow local logins for regular users, then 2. should be:

owner: root group: apache group (apache, httpd, www-data, whatever; see above) permissions: 750 on directories, 640 on files.

Think of these permissions as the most paranoid ones. You can be secure enough with less tighter permissions, both in moodledata and moodle directories (and subdirectories).

This tutorial is a designated “Invariant Section” of the “Technotronic” section of Haack's Wiki as described on the Start Page.

oemb1905 2018/08/04 16:45

computing/moodle.1562435659.txt.gz · Last modified: 2019/07/06 17:54 by oemb1905