Moodle is a vastly popular open-source software management system designed to facilitate learning in schools, universities, workplaces. Originally built in 2002 as a tool to help educators create online courses based on interaction and collaborative construction of content, the free software is now gaining more and more popularity by the year.
Through Moodle, you can create and deliver learning resources such as courses, readings, and discussion boards and manage access to these materials by assigning user roles that come with different levels of access to the existent information.
In this tutorial, we aim to teach you how to easily set up Moodle on your Ubuntu server. Before the installation, you’ll need to make sure you have a 1GB Ubuntu 16.04 server with a minimum of 200MB of disk space for the Moodle code and as much as you need to store your content. Also, you’ll need a non-root user with sudo privileges, a firewall and of course, the LAMP stack already set up and ready for use.
- The first step prior to the actual installation is to install all of the prerequisite libraries using the package manager. Make sure you have the latest list of packages by entering this command:
sudo apt-get update
- Next, install Moodle’s dependencies:
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
- Now you can go ahead and install Moodle. You need to download it first using curl. The following command will instruct your server go to the Moodle website and retrieve the compressed package that contains the entire current, stable version of Moodle into the file moodle.tgz. The -L flag tells curl to follow redirects.
curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz
- Time to uncompress the file with the tar program and place the resulting files in the web document root:
sudo tar -xvzf moodle.tgz -C /var/www/html
- Next, you’ll need to create a directory outside the web root where Moodle can store all the course-related data that will be stored on the server, but not in the database. To do that, enter this command:
sudo mkdir /var/moodledata
- To make sure that the web service user www-data can access the directory, set its ownership like so:
sudo chown -R www-data /var/moodledata
- Now enter this command so that only the owner has full permissions:
sudo chmod -R 0770 /var/moodledata
- The next step is configuring the database. For that purpose, you’ll need to create the MySQL database where Moodle will store most of its data. First, a few changes must be made to the MySQL configuration file so that your MySQL installation is compatible with Moodle. Open the MySQL configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
- Once you’ve opened it, add the following bolded lines to the ‘Basic Settings’ area:
... [mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda ## Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. ...
- Save the file and restart the MySQL server. Now it is time to create the Moodle database by interacting with the MySQL command-line interface. Execute this command:
mysql -u root -p
- When prompted, supply the root password you set when you installed MySQL. After logging in, you’ll see the mysql> prompt. Run the following command to create the database:
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- Now go ahead and create a Moodle user by executing this command:
create user 'moodler'@'localhost' IDENTIFIED BY 'moodlerpassword'; (replace moodler with your own username)
- And give the user permission to edit the database. This user will need to create tables and change permissions:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodler'@'localhost' IDENTIFIED BY 'moodlerpassword';
- Now exit the MqSQL command-line interface, like so:
- All that is left for you to do now is to configure Moodle in the browser. In order to save any changes made past this point, you need to temporarily alter the permission for the Moodle web root.
sudo chmod -R 777 /var/www/html/moodle
- Navigate to http://your_server_ip/moodle. Once there, you will need to follow a set of simple steps in order to complete the configuration.
- First, set the language you wish to use and click Next.
- On the next screen, set the Data Directory to /var/moodledata and click Next. Then, on the Choose Database Driver page, set Database driver to Improved MySQL (native mysqli). Click next when you’re done.
- On the Database setting page, enter the username and password for the Moodle MySQL user you previously created. Click Next to continue.
- Review the license agreement and confirm that you agree to its terms by pressing Continue. Also, review the Server Checks page for any possible issues.
- Moodle will install several of its components, displaying “Success” messages for each. Scroll to the bottom and press Continue.
- After the installation is complete, you’ll be taken to a page where you can set up your administrator account for Moodle. Fill in all the necessary fields. Once you’re done, click Update profile.
- On the Front Page Settings screen, fill in the Full site name, the Short name for site, set a location, and select whether you want to allow self-registration via email. Then click Save changes.
- Once the setup is complete, it is recommend that we revert the change you made earlier regarding the permission for the Moodle web root.
sudo chmod -R 0755 /var/www/html/moodle
This concludes our tutorial on how to set up Moodle on your Ubuntu server. If you’ve followed all the steps listed above, then your Moodle should properly set up and ready to be used. Congratulations!