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:
- An Ubuntu server with root or sudo access.
- An active internet connection.
- Basic knowledge of Linux terminal commands.
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
- Download the Moodle installation directly on your server:
- Visit Moodle.org, navigate to the Downloads section, and click on the big green Moodle link to find the latest available version.
- Click on the "Download tgz" button
- The Moodle download will start. Cancel it, then right click on the link that says "click here to download manually" and choose 'copy link'
- Update the
wget
command to use the URL you just copied instead of version 4.5. - Move the downloaded file to the web server's root directory:
- Navigate to the directory and extract the file:
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:
sudo mv moodle-latest-405.tgz /var/www/html/
cd /var/www/html/
sudo tar -xf moodle-latest-405.tgz
Step 4: Configure Moodle Data Directory
- Navigate one directory up to the
www
folder: - Create the
moodledata
folder: - Grant ownership to the web server user (
www-data
):
cd /var/www/
sudo mkdir moodledata
sudo chown www-data moodledata
Step 5: Set Up the Database
Moodle requires a database. Follow these steps:
- Open the MySQL prompt:
- Create a database for Moodle:
- Create a user and grant it access to the database (replace
yourpassword
with a secure password): - Exit MySQL:
sudo mysql
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
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;
quit
Step 6: Complete Moodle Setup in Your Browser
- Open your browser, go to the Moodle URL on your server, for example:
- Follow the setup wizard:
- Choose your preferred language.
- Set the Data Directory to
/var/www/moodledata
. - Enter the database details created in Step 5.
http://192.168.0.1/moodle
Step 7: Fix Configuration and PHP Settings
During the setup, you may encounter a few warnings. Here's how to address them:
- If Moodle cannot write the
config.php
file: - Restart Apache:
- If prompted to increase
max_input_vars
:
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
.
sudo systemctl restart apache2
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
- Refresh the setup page and continue with the installation.
- Provide admin credentials, an email address, and a name for your Moodle site.
- 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!