How to Install Moodle LMS on Ubuntu 24.04 Server

Moodle is an open-source learning management system (LMS) designed to help educators create online courses. This guide will show you how to install Moodle on an Ubuntu 24.04 server.

Step 1: Update Your System

  • Before installing Moodle, ensure that your system is up-to-date by running the following commands:
sudo apt update && sudo apt upgrade -y
    

Step 2: Install Apache, MySQL, and PHP

  • Moodle requires a web server, a database, and PHP. Install Apache, MySQL, and PHP with the following command:
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-xml php-mbstring php-zip php-intl php-gd php-curl php-soap -y
    

Step 3: Configure MySQL

  • Secure the MySQL installation by running:
sudo mysql_secure_installation
    

Follow the prompts to secure your MySQL server (set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload privileges).

  • Log into MySQL as the root user:
sudo mysql -u root -p
    
  • 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 'your_password';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
    

Step 4: Download and Set Up Moodle

  • Navigate to the web root directory and download the latest version of Moodle:
cd /var/www/html
sudo wget https://download.moodle.org/stable402/moodle-latest-402.tgz
    
  • Extract the Moodle archive:
sudo tar -zxvf moodle-latest-402.tgz
    
  • Move the Moodle files to the `/var/www/html/moodle` directory:
sudo mv moodle /var/www/html/moodle
    
  • Create a Moodle data directory (where Moodle will store its files):
sudo mkdir /var/www/moodledata
sudo chown -R www-data:www-data /var/www/moodledata /var/www/html/moodle
sudo chmod -R 755 /var/www/moodledata /var/www/html/moodle
    

Step 5: Configure Apache for Moodle

  • Create a new Apache configuration file for Moodle:
sudo nano /etc/apache2/sites-available/moodle.conf
    

Add the following configuration:

    ServerAdmin [email protected]
    DocumentRoot /var/www/html/moodle
    ServerName example.com

    
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    

    ErrorLog ${APACHE_LOG_DIR}/moodle_error.log
    CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined

    

Enable the Moodle site and rewrite module, then restart Apache:

sudo a2ensite moodle.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
    

Step 6: Complete Moodle Setup via Browser

  • Open a web browser and navigate to your server’s domain or IP address:

URL: http://your-server-ip or http://your-domain

Follow the on-screen installation wizard to configure Moodle. Provide the database credentials created in Step 3 and configure the necessary settings.

Step 7: Final Configuration

  • During the installation process, Moodle will guide you through setting up the administrator account and configuring your site's main settings.

Conclusion

You have successfully installed Moodle LMS on an Ubuntu 24.04 server. You can now log in to the Moodle dashboard and start creating courses and managing your learning environment.

Was this answer helpful? 0 Users Found This Useful (0 Votes)