How to Install Moodle LMS On Ubuntu Server 24.04

Last update: 12-07-2024

If you're looking to set up a robust and customizable Learning Management System (LMS), Moodle is an excellent choice. In this guide, I'll walk you through the process of installing Moodle on an Ubuntu server. By the end, you'll have a fully functional Moodle site ready to host your courses.

Why Moodle?

Moodle is one of the most widely used open-source LMS platforms, perfect for educators and organizations of all sizes. Its flexibility, rich feature set, and active community make it an excellent choice for online learning environments.

Prerequisites

Before starting, ensure you have:

Step 1: Connect to Your Ubuntu Server

To begin, connect to your server using SSH. Replace 192.168.0.1 with your server's IP address:

ssh ubuntu@192.168.0.1

Update the server's package list and upgrade installed packages to ensure everything is up-to-date:

sudo apt update
sudo apt upgrade -y

Step 2: Install Required Software

Moodle requires a web server, a database, and PHP with specific extensions. Install them all in one command:

sudo apt install -y mysql-client mysql-server apache2 php php-mysql php-mbstring php-xml php-curl php-zip php-gd php-intl php-soap

Step 3: Download and Extract Moodle

  1. Download the Moodle installation directly on your server:
  2. wget https://download.moodle.org/download.php/direct/stable405/moodle-latest-405.tgz

    Note: This will download Moodle 4.5. If you want to make sure you have the latest version, follow these steps:

    1. Visit Moodle.org, navigate to the Downloads section, and click on the big green Moodle link to find the latest available version.
    2. Click on the "Download tgz" button
    3. The Moodle download will start. Cancel it, then right click on the link that says "click here to download manually" and choose 'copy link'
    4. Update the wget command to use the URL you just copied instead of version 4.5.
  3. Move the downloaded file to the web server's root directory:
  4. sudo mv moodle-latest-405.tgz /var/www/html/
  5. Navigate to the directory and extract the file:
  6. cd /var/www/html/
    sudo tar -xf moodle-latest-405.tgz

Step 4: Configure Moodle Data Directory

  1. Navigate one directory up to the www folder:
  2. cd /var/www/
  3. Create the moodledata folder:
  4. sudo mkdir moodledata
  5. Grant ownership to the web server user (www-data):
  6. sudo chown www-data moodledata

Step 5: Set Up the Database

Moodle requires a database. Follow these steps:

  1. Open the MySQL prompt:
  2. sudo mysql
  3. Create a database for Moodle:
  4. CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  5. Create a user and grant it access to the database (replace yourpassword with a secure password):
  6. CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword';
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER ON moodle.* TO 'moodleuser'@'localhost';
    FLUSH PRIVILEGES;
  7. Exit MySQL:
  8. quit

Step 6: Complete Moodle Setup in Your Browser

  1. Open your browser, go to the Moodle URL on your server, for example:
  2. http://192.168.0.1/moodle
  3. Follow the setup wizard:
    • Choose your preferred language.
    • Set the Data Directory to /var/www/moodledata.
    • Enter the database details created in Step 5.

Step 7: Fix Configuration and PHP Settings

During the setup, you may encounter a few warnings. Here's how to address them:

  1. If Moodle cannot write the config.php file:
  2. cd /var/www/html/moodle/

    Create the file manually using Nano:

    sudo nano config.php

    Copy the configuration provided by Moodle, save it with Ctrl + S, and exit with Ctrl + X.

  3. Restart Apache:
  4. sudo systemctl restart apache2
  5. If prompted to increase max_input_vars:
  6. Edit the PHP configuration file:

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

    Find max_input_vars, remove the semicolon, and set its value to 5000:

    max_input_vars = 5000

    Save the file and restart Apache:

    sudo systemctl restart apache2

Step 8: Finalize Installation

  1. Refresh the setup page and continue with the installation.
  2. Provide admin credentials, an email address, and a name for your Moodle site.
  3. Once installation is complete, configure additional settings such as support email and save changes.

Step 9: Access Your Moodle Site

Congratulations! Your Moodle site is now up and running. Access it via:

http://192.168.0.1/moodle

You can now start customizing your Moodle site and creating courses!

StocksComparison.com ad
 

0 Comments

Add a new comment: