How to Install Moodle 4.5+ on Ubuntu 24.04

How to Install Moodle 4.5+ on Ubuntu 24.04

Bitnesia Software Mar 25, 2026 449 ID

Digital transformation in education demands learning platforms that are robust, flexible, and secure. A Learning Management System (LMS) has become the backbone for schools, universities, and companies to conduct remote training.

Among many choices, Moodle remains the king of the open-source LMS world. This article will guide you step-by-step, from server preparation to a ready-to-use Moodle, using Ubuntu VPS infrastructure and the Apache web server.

What is Moodle?

Moodle (Modular Object-Oriented Dynamic Learning Environment) is the most popular learning platform in the world. Moodle is designed to provide a secure and integrated system for educators, administrators, and learners to create personalized learning environments. Its open-source nature means Moodle is free of license fees and has thousands of plugins developed by the community.

Key Features of Moodle

Why do educational institutions choose Moodle?

  • Modern & Easy to Use: Responsive interface for desktop and mobile.
  • Complete Assessment Tools: Supports quizzes, assignments, workshops, and automated grading.
  • Collaboration: Discussion forums, wikis, and glossaries for active learning.
  • File Management: Integration with Google Drive, Dropbox, and OneDrive.
  • Scalability: Capable of handling hundreds to millions of users.

System Requirements

Before starting the installation, ensure your server meets these minimum specifications for Moodle version 4.5+:

  • Disk Space: Minimum 25GB (larger is recommended to store course materials).
  • RAM: Minimum 2GB (4GB or more is recommended for smooth performance).
  • Database: MariaDB 10.6.7+ or MySQL 8.0+.
  • PHP: Version 8.1, 8.2, or 8.3.
  • This tutorial uses the Ubuntu LTS operating system.

Step 1: Server Preparation

We will use the LAMP stack (Linux, Apache, MariaDB, PHP).

Update the system and ensure the package repositories are up to date:

sudo apt update
sudo apt upgrade -y

Install Apache and certbot:

sudo apt install apache2 certbot python3-certbot-apache -y

Install MariaDB:

sudo apt install mariadb-server -y

Add the PHP PPA repository by Ondřej Surý:

sudo add-apt-repository ppa:ondrej/php -y
sudo apt upgrade -y

Install PHP 8.3 and required extensions:

sudo apt install libapache2-mod-php8.3 php8.3 php8.3-cli php8.3-common \
  php8.3-apcu php8.3-mbstring php8.3-gd php8.3-intl \
  php8.3-xml php8.3-soap php8.3-bcmath php8.3-mysql php8.3-zip \
  php8.3-curl php8.3-tidy php8.3-imagick -y

Open the php.ini configuration:

sudo nano /etc/php/8.3/apache2/php.ini

Search for the max_input_vars parameter (use Ctrl+W), uncomment it by removing the semicolon, and change its value to 5000:

max_input_vars = 5000

Save the file (Ctrl+O, Enter) and exit (Ctrl+X).

Create the Database

Access the MariaDB console:

sudo mysql

Run the following SQL commands (replace 'strongpassword' with your own):

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodle'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'localhost';
FLUSH PRIVILEGES;
exit

Step 3: Download and Prepare Moodle Files

We will download the Moodle v4.5 source code and set up the directory structure.

Download Moodle:

wget https://packaging.moodle.org/stable405/moodle-latest-405.tgz

Extract the file:

tar xzvf moodle*.tgz

Set directories and permissions: We will place Moodle in the /var/www directory and create the moodledata folder (this folder must be located outside the public web access for security).

sudo mkdir -p /var/www/moodle.yourdomain.com/moodledata
sudo mv moodle /var/www/moodle.yourdomain.com
sudo chown -R www-data:www-data /var/www/moodle.yourdomain.com
sudo chmod -R 755 /var/www/moodle.yourdomain.com

Step 4: Configure Apache Virtual Host

To access Moodle via the domain moodle.yourdomain.com, we need to create a Virtual Host configuration.

Create a new configuration file:

sudo nano /etc/apache2/sites-available/moodle.yourdomain.com.conf

Insert the following configuration:

<VirtualHost *:80>
    ServerName moodle.yourdomain.com
    DocumentRoot /var/www/moodle.yourdomain.com/moodle
    
    <Directory /var/www/moodle.yourdomain.com/moodle>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog /var/log/apache2/moodle.yourdomain.com_error.log
    CustomLog /var/log/apache2/moodle.yourdomain.com_access.log combined
</VirtualHost>

Enable the configuration and restart Apache:

sudo a2ensite moodle.yourdomain.com
sudo systemctl restart apache2

Step 5: Install SSL (HTTPS)

Use Certbot to secure your connection with a free SSL certificate from Let’s Encrypt:

sudo certbot --non-interactive \
  -m [email protected] \
  --agree-tos \
  --no-eff-email \
  --apache -d moodle.yourdomain.com \
  --redirect

Step 6: Web Installation Wizard

The server is now ready. The rest of the installation will be done through your web browser.

  1. Open your browser and access your domain: https://moodle.yourdomain.com.
  2. Language: Select English (en), then click Next.
  3. Confirm paths: Ensure the Web addressMoodle directory, and Data directory are correct based on the configuration in Step 3. Click Next.
  4. Database driver: Select MariaDB (native/mariadb). Click Next.
  5. Database settings:
    • Database name: moodle
    • Database user: moodle
    • Database password: strongpassword (the one you created earlier).
    • Click Next.
  6. Confirm copyright: Read and click Continue.
  7. Server checks: Moodle will check if all PHP extensions are installed. If all statuses are green (OK), click Continue.
  8. Installation: The system will install the core modules. This takes 1-2 minutes. Once the “Success” message appears at the bottom, click Continue.
  9. Admin Account: Enter details for the main Administrator account (Username, Password, Email). Click Update profile.
  10. Site Settings: Enter the Full site nameShort name, and Timezone.
  11. Support Email: Enter the email for support. Click Save changes.
  12. Registration: You can choose Skip regarding registration to Moodle HQ.

Conclusion

Congratulations! You have successfully built your own e-learning system using Moodle on an Ubuntu server. Your LMS is now ready to create courses, enroll students, and manage learning materials at moodle.yourdomain.com. As a recommended next step, configure a Cron Job to ensure email notifications and Moodle’s automated tasks run smoothly, and customize the appearance by installing a theme that matches your institution’s identity.

I love keeping these tutorials free for everyone. If you've saved time or learned something new today, consider making a small donation to keep this site ad-free.

Support Free Content

Related Posts