How To Install Moodle on Ubuntu 24.04 LTS
In this tutorial, we will show you how to install Moodle on Ubuntu 24.04 LTS. Moodle, the world’s most popular open-source learning management system (LMS), empowers educators to create dynamic online learning environments.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Moodle Learning Platform or course management system on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A server with at least 2GB RAM and 20GB of free disk space.
- A domain name pointed to your server’s IP address.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
- An Ubuntu 24.04 system with root access or a user with sudo privileges.
Install Moodle on Ubuntu 24.04
Step 1. Updating the Package Repository.
Before proceeding with the installation of Moodle, it’s crucial to update your Ubuntu 24.04 LTS system to the latest version. This ensures that you have access to the most recent software packages and security patches. To update your system, open a terminal and run the following commands:
sudo apt update sudo apt upgrade
These commands will refresh the package list and upgrade any outdated packages to their latest versions.
Step 2. Installing Apache.
Apache is a robust and reliable web server that works seamlessly with Moodle:
sudo apt install apache2 sudo systemctl start apache2 sudo systemctl enable apache2
Verify Apache’s status:
sudo systemctl status apache2
You can verify that Apache is running by accessing your server’s IP address in a web browser. You should see the Apache2 Ubuntu Default Page.
Step 3. Installing and Configuring PHP.
Moodle requires PHP to function. Ubuntu 24.04 LTS typically includes PHP 8.3, but Moodle may require specific versions. Here’s how to install PHP and necessary extensions:
sudo apt install php php-fpm php-cli php-curl php-gd php-intl php-mysql php-xml php-xmlrpc php-ldap php-zip php-soap php-mbstring
To verify that PHP is installed correctly, run:
php -v
After installation, configure PHP for optimal performance:
sudo nano /etc/php/8.3/apache2/php.ini
Adjust the following settings:
memory_limit = 256M upload_max_filesize = 100M post_max_size = 100M max_execution_time = 300 max_input_time = 300
Save the file and exit the editor. Restart Apache to apply changes:
sudo systemctl restart apache2
Step 4. Installing and Configuring MySQL.
MySQL serves as the database backend for Moodle:
sudo apt install mysql-server sudo systemctl start mysql sudo systemctl enable mysql
Secure your MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and remove insecure default settings.
Moodle needs a dedicated database to store its data. Follow these steps to create a MySQL database and user for Moodle.
sudo mysql -u root -p
Enter your MySQL root password, then execute:
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Step 5. Installing Moodle on Ubuntu 24.04.
Moodle’s Git repository allows for easy installation and future updates:
cd /opt sudo git clone git://git.moodle.org/moodle.git cd moodle sudo git branch --track MOODLE_400_STABLE origin/MOODLE_400_STABLE sudo git checkout MOODLE_400_STABLE
Next, move the Moodle files to the web directory:
sudo mv /opt/moodle /var/www/html/ sudo chown -R www-data:www-data /var/www/html/moodle sudo chmod -R 755 /var/www/html/moodle
Create the Moodle data directory:
sudo mkdir /var/moodledata sudo chown -R www-data:www-data /var/moodledata sudo chmod -R 0777 /var/moodledata
Step 6. Configuring Apache for Moodle.
To serve Moodle correctly, you need to create an Apache configuration file.
sudo nano /etc/apache2/sites-available/moodle.conf
Add the following configuration:
<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/moodle ServerName your_domain_or_IP <Directory /var/www/html/moodle> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/moodle_error.log CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined </VirtualHost>
Replace your_domain_or_IP
with your actual domain name or server IP address.
Enable the new site and the Apache rewrite module:
sudo a2ensite moodle.conf sudo a2enmod rewrite sudo systemctl restart apache2
Step 7. SSL Configuration.
To secure your Moodle site with SSL, install Certbot:
sudo apt install certbot python3-certbot-apache
Then obtain and install an SSL certificate:
sudo certbot --apache
Follow the prompts to complete the SSL installation. This will secure your Moodle installation with HTTPS.
Step 8. Configuring the Firewall
Ubuntu’s Uncomplicated Firewall (UFW) provides a user-friendly way to manage your server’s security. Enable HTTP and HTTPS traffic:
sudo ufw allow http sudo ufw allow https sudo ufw enable sudo ufw status
These commands open ports 80 and 443, essential for web traffic.
Step 9. Completing Moodle Installation via Web Interface.
Navigate to http://your_server_ip/moodle
in your web browser to start the Moodle web installer. Follow the Installation Steps:
- Select Language: Choose your preferred language.
- Confirm Paths: Ensure that the paths are correct.
- Enter Database Settings: Use the database name, user, and password you created earlier.
- Configure Admin Account: Set up an admin account with a username and password.
- Complete Installation: Click through the remaining prompts to finish the installation.
Congratulations! You have successfully installed Moodle. Thanks for using this tutorial for installing Moodle Learning Platform or course management system on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Moodle website.