Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Install Moodle on Ubuntu 20.04
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Moodle is a popular, free, and open-source Learning Management System (LMS). With Moodle, you can create a fully-featured website for education and training courses, suitable for fully online, hybrid, and in-person classroom experiences. The Moodle platform is highly customizable and takes a modular approach to features, so it is extensible and adaptable to your needs. This guide shows you how to get a Moodle website up and running on an Ubuntu 20.04 server.
Before You Begin
If you have not already done so, create a Linode account and Compute Instance. See our Getting Started with Linode and Creating a Compute Instance guides.
Follow our Setting Up and Securing a Compute Instance guide to update your system. You may also wish to set the timezone, configure your hostname, create a limited user account, and harden SSH access.
Install and configure a LAMP (Linux, Apache, MySQL, and PHP) stack. Follow the How to Install a LAMP Stack on Ubuntu 20.04 guide for instructions.
For this guide, you do not need to configure a virtual host for Apache. However, you should follow all other non-optional sections in the guide linked above.
sudo
. If you are not familiar with the sudo
command, see the
Linux Users and Groups
guide.Install the Prerequisites
Install the prerequisites for Moodle. This includes software and PHP modules that support Moodle’s features and Git for installing Moodle and keeping it up to date.
sudo apt install graphviz aspell ghostscript clamav php7.4-pspell php7.4-curl php7.4-gd php7.4-intl php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-ldap php7.4-zip php7.4-soap php7.4-mbstring git
Restart Apache to load the modules.
sudo systemctl restart apache2
Download Moodle
Change into the
/opt
directory, clone the Moodle Git repository and change into the resultingmoodle
subdirectory.cd /opt sudo git clone git://git.moodle.org/moodle.git cd moodle
Determine the latest stable Moodle release from Moodle’s official list of releases . At the time of writing, the latest stable release is 3.10.
The following command lists the branches in the Git repository. From that list, identify the branch associated with the latest stable release. For release 3.10, this is
MOODLE_310_STABLE
.sudo git branch -a
Track and then check out the branch you identified.
sudo git branch --track MOODLE_310_STABLE origin/MOODLE_310_STABLE sudo git checkout MOODLE_310_STABLE
Copy the directory with the Moodle repository into the
/var/www/html
directory. Then, modify the new Moodle directory’s permissions to grant read, execute, and write access to any user.sudo cp -R /opt/moodle /var/www/html/ sudo chmod -R 0777 /var/www/html/moodle
Note Write access to this directory is only meant to be granted temporarily. Once the Moodle installation is completed in the steps below, the permissions are modified to restrict write access to the directory owner (theroot
user).Create a
/var/moodledata
directory, makewww-data
its owner, and modify its permissions to grant all users read, execute, and write access.sudo mkdir /var/moodledata sudo chown -R www-data /var/moodledata sudo chmod -R 0777 /var/moodledata
Set Up the MySQL Server
Open the MySQL interface as the root user.
sudo mysql -u root -p
Use the following MySQL command to create a database for Moodle.
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Create a Moodle MySQL user, and give it the required permissions on the Moodle database. In the following example, replace
moodle-user
andpassword
with the username and password, respectively, you would like to use for the Moodle MySQL user.CREATE USER 'moodle-user'@'localhost' IDENTIFIED BY 'password'; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodle-user'@'localhost';
Exit the MySQL interface using the
quit
command.
Complete the Moodle Installation
In a web browser, navigate to the Moodle URL, which is your server’s domain name followed by
/moodle
. So, if your server’s domain name isexample.com
, then the Moodle URL would beexample.com/moodle
.Follow the prompts to complete the Moodle setup. Enter the default options or your preferences for all settings except the following:
Enter
/var/moodledata
for Data directory when prompted to confirm paths.Choose the Improved MySQL option when prompted to select a database driver.
Follow the example in the image below when you are asked to enter database settings. Replace
moodle-user
andpassword
with the username and password, respectively, that you used when creating the Moodle MySQL user above:
Review the release information, ensure that no issues are indicated, and continue. Allow the next page to load fully — it may take some time — and ensure that all of the components listed indicate “Success”. Then, continue.
Complete the form for creating a Moodle site administrator and, on the next page, complete the form with information about your Moodle site.
Return to your server’s command line, and modify the Moodle directory’s permissions to prevent writing except by the directory owner (the root user):
sudo chmod -R 0755 /var/www/html/moodle
Configure the Moodle’s System Paths
Configuring the system paths for Moodle, while optional, enhances your Moodle site’s performance. The configuration can be done from the Moodle administration interface, using the following steps:
Navigate again to your Moodle website (
example.com/moodle
) and select Site Administration from the left menu.Click the Server tab and select System paths.
On the form presented, complete the fields as follows:
Path to du, enter
/usr/bin/du
.Path to aspell, enter
/usr/bin/aspell
.Path to dot, enter
/usr/bin/dot
.
Click the Save changes button.
Set Up an SSL Certificate
Although not required, it is recommended that you secure your Moodle site using an SSL certificate. This guide uses Certbot to create a free certificate from Let’s Encrypt .
Update the Snap app store. Snap provides application bundles that work across major Linux distributions and is installed by default with all Ubuntu releases since 16.04.
sudo snap install core && sudo snap refresh core
Remove any existing Certbot installation.
sudo apt remove certbot
Install Certbot.
sudo snap install --classic certbot
Download a certificate for your site.
sudo certbot --apache
Certbot prompts you to enter your site’s domain name. Do so to complete the installation of the SSL certificate.
Certbot includes a chron job that automatically renews your certificate before it expires. You can test the automatic renewal with the following command:
sudo certbot renew --dry-run
Using your preferred text editor, open the Moodle configuration file,
/var/www/html/moodle/config.php
. Change the$CFG->wwwroot
value to usehttps
instead ofhttp
. Replaceexample.com
in the following example with your site’s domain name.$CFG->wwwroot = 'https://example.com/moodle';
Restart the Apache server.
sudo systemctl restart apache2
Next Steps
You are now ready to start using Moodle. To get started, take a look at Moodle’s Admin quick guide , which shows you how to start customizing the look of your site and how to add users and courses. Then, review the Teacher quick guide for a walkthrough on how you can manage a course. From there, check out the rest of Moodle’s documentation library for guides on the many ways you can customize your site and for instructions on getting the most out of it.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on