Moodle can be installed on many different operating systems, including Ubuntu. While some programs such as Fantastico or Softaculous use graphical user interfaces that allow users to install software such as Moodle, some users prefer to manually install the software instead. In this article, we will outline the installation process for Moodle on Ubuntu. Please note that these steps require use of a SSH command-line interface to complete the installation. It is recommended that only users familiar with command-line operations attempt to install Moodle in this fashion.
Experience unrestricted processing power on state-of-the-art hardware and your preferred operating system with Bare Metal Hosting!
Ubuntu, Debian, OpenSUSE, or Load your own OS Unmanaged Hosting Perfect for SysAdmins Dedicated Resources
- Before you can install Moodle, you will need to install a few other technologies. First, install the Apache web server software. Then, install the MySQL database server as well as the requisite version PHP.
- Next, you will need to install the necessary modules for Moodle using the following command:
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
- After these modules have been installed, restart Apache.
sudo service apache2 restart
- Once Apache has restarted, install git in order to access git repositories. This can be done using the following command:
sudo apt install git
- Once git is installed, change directory into /opt folder with the cd command:
- While still in the /opt folder, download the Moodle code using the git command:
sudo git clone git://git.moodle.org/moodle.git
- Once downloaded, change directory into the moodle folder, again with cd:
- To get a list of available git branches, use the following command:
sudo git branch -a
- Next, tell git which branch to use with the following command:
sudo git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE
- Once that is done, check out the current version of Moodle being used with the following command:
sudo git checkout MOODLE_39_STABLE
- Before proceeding to the next steps, first create a database in mysql for your Moodle site.
- Once you’ve created the database, copy the Moodle data to the website root folder /var/www/html with the following command:
cp -R /opt/moodle /var/www/html
- Also, make a moodledata folder in the /var/ folder using the mkdir command:
- Once that folder has been created, update its ownership with the following command:
sudo chown -R www-data /var/moodledata
- Next, update the permissions for the moodle and moodledata folder using the chmod command:
sudo chmod -R 777 /var/moodledata
sudo chmod -R 0755 /var/www/html/moodle
- Before running the installer, update the permissions of your Moodle folder using the following command:
sudo chmod -R 777 /var/www/html/moodle
- In your web browser, go to your domain name followed by /moodle to run the installer. It should then ask you to select a language, specify your web address, and the document root for the site. This document root should be /var/www/html/moodle.
The installer will also ask you to specify a data directory, which is the /var/moodledata folder we created in step 8. The installer will then ask you to specify which database driver you use (typically MySQL or MariaDB), and then prompt you to input the database information you created in step 6.
- Once you’ve finished with this, the installer should prompt you to accept the terms of the installation and then allow you to press Continue to complete the installation. You will then have the opportunity to create an administrator account for Moodle dashboard access.
- Now that the installation is complete, you will want to revert the root directory permissions to their default using the following command:
sudo chmod -R 0755 /var/www/html/moodle
Congratulations, you have now installed Moodle on Ubuntu!
Want to learn more about Moodle? Check out our getting started guide here!