Moodle is a popular open-source learning management system (LMS) used by many educational institutions and organizations to create and manage online courses. In this article, we will show you how to install Moodle on an Ubuntu Server 22.04 machine.
Before we begin, make sure that your Ubuntu Server 22.04 is up-to-date by running the following commands:
sudo apt update
sudo apt upgrade
Next, we will install some dependencies that are required for Moodle. Run the following command to install Apache, PHP, and MariaDB:
sudo apt install apache2 mariadb-server libapache2-mod-php7.4 php7.4-xml php7.4-gd php7.4-curl php7.4-zip php7.4-mysql
Once the installation is complete, start the Apache and MariaDB services and enable them to start automatically on boot:
sudo systemctl start apache2
sudo systemctl start mariadb
sudo systemctl enable apache2
sudo systemctl enable mariadb
Next, we will create a database and a user for Moodle. Log in to the MariaDB shell using the following command:
sudo mysql
In the MariaDB shell, run the following commands to create a database and a user for Moodle:
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
Replace password
with a strong password for the Moodle database user.
Now, we will download and install Moodle. Visit the Moodle download page (https://download.moodle.org/download.php) and download the latest version of Moodle in ZIP format.
Once the download is complete, extract the downloaded file and move the extracted directory to the /var/www/html
directory:
unzip moodle-latest-38.zip
sudo mv moodle /var/www/html/
Next, we need to give the Apache user (www-data
) permission to access the Moodle directory. Run the following command to do so:
sudo chown -R www-data:www-data /var/www/html/moodle
Now, open the Apache default virtual host configuration file (/etc/apache2/sites-enabled/000-default.conf
) in a text editor and add the following lines at the end of the file:
<Directory /var/www/html/moodle>
Options +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Save the file and exit the editor. Then, restart the Apache service for the changes to take effect:
sudo systemctl restart apache2
Now, open a web browser and navigate to http://your-server-ip/moodle
(replace your-server-ip
with the actual IP address of your Ubuntu server). You should see the Moodle installation page, where you can follow the on-screen instructions to complete the Moodle installation process.”