​Unlock Seam​less Learning: A Step-by-Step Guide to Installing Moodle on Ubuntu VPS Server

Moodle is a top-tier open-source learning platform. Designed with a focus on learners, educators, and administrators, Moodle offers a single robust, secure, and integrated platform to establish personalized learning environments.

​​Ubuntu Virtual Private Server (VPS) is a virtual dedicated server running the Ubuntu Server operating system. Ubuntu Server is an operating system based on the Linux Operating System.

​​Before we delve into the installation process, let's explore how Moodle's robust features, including customizable user courses and cohort management, empower educators and administrators to create tailored learning environments.

​​In this step-by-step guide, we'll walk you through the seamless installation of Moodle on an Ubuntu VPS server, unlocking a world of possibilities for personalized online learning. You’ll install Moodle using a command line interface and configure it in your browser.

​​Prerequisites

​​You’ll need the following to follow along with the tutorial

  • ​​Ubuntu VPS Server: Ensure you have access to an Ubuntu VPS server. If you don’t have one, consider obtaining a reliable VPS service from providers like DigitalOcean or Namecheap. They both provide reputable VPS hosting services.

  • ​​Terminal Access: Get comfortable with accessing the server via the terminal. If you're new to the command line, no worries—we'll guide you through each step.

  • ​​Domain Name: If you plan to use a custom domain for your Moodle instance, ensure that the domain is configured and points to the IP address of your VPS.

​​Getting started

​​Step 1: Server Login

​​To kick off the Moodle installation process, you must log into your Ubuntu VPS server.

​​Ensure you have your server credentials, including the IP address, username, and password.

  1. ​​Open Your Terminal: Begin the login process by launching your terminal.

  2. Type the SSH Command: Enter the following command in the terminal:

    ssh root@IP_address
    

    Replace the IP_address text with your actual IP address. Press Enter to execute the command.

  3. Enter Your Password: You'll be asked for your password in the next step. Keep in mind that the password you type won't be visible. Press Enter to complete the login process.

​​Congratulations on successfully logging into your Ubuntu VPS server! With that done, we can now move forward with the Moodle installation process.

​​Step 2: Update and Install Essential Components

​​After logging in successfully, you will now install the necessary packages and update the system.

​​Follow these steps and press the Enter key after every command:

  1. ​​Update System Packages:
    ​​sudo apt update && sudo apt upgrade
    
  2. ​​Install Apache, MySQL, PHP, and Other Dependencies:
    ​​sudo apt install apache2 mysql-client mysql-server php8.1 libapache2-mod-php
    
  3. Restart MySQL Service:
    ​​sudo service mysql restart
    

​​Step 3: Secure MySQL Installation

​​After successfully updating essential components, it is crucial to secure your MySQL connection. Follow these steps:

  1. ​​Run MySQL Secure Installation:
    ​​sudo mysql_secure_installation
    
    if you encounter any error during the process, refer to this technical guide How To Install MySQL on Ubuntu 20.04 for troubleshooting.

​​Step 4: Install Additional Software

​​Now, you will install crucial additional software that is necessary for Moodle. Ensure the PHP extension version is the same as the PHP version that was installed. Follow these steps.

  1. ​​Install necessary PHP extensions and dependencies:

    sudo apt install graphviz aspell ghostscript clamav php8.1-pspell php8.1-curl php8.1-gd php8.1-intl php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-ldap php8.1-zip php8.1-soap php8.1-mbstring
    

    Change 8.1​ to the PHP version you installed to ensure compatibility.

  2. Restart the Apache server to apply changes:

    ​​sudo service apache2 restart
    
  3. ​​Install version control software (Git):
    ​​sudo apt install git​​
    

​​Step 5: Download Moodle from the repository

​​Follow these steps to download Moodle from the Git repository:

  1. ​​Change Directory to /opt:
    ​​cd /opt
    
  2. Clone the Moodle Repository:
    ​​sudo git clone git://git.moodle.org/moodle.git
    
  3. Change Directory to the Cloned Moodle Repository:
    ​​cd moodle
    
  4. List Available Branches:
    ​​sudo git branch -a
    
  5. Create a Local Branch Tracking a Remote Branch (in this case, MOODLE_412_STABLE):

    ​​sudo git branch --track MOODLE_412_STABLE origin/MOODLE_412_STABLE
    

    ​​Make sure to replace MOODLE_412_STABLE​ with your desired Moodle version to ensure working with a stable branch.

  6. Switch to the MOODLE_412_STABLE Branch:

    ​​sudo git checkout MOODLE_412_STABLE​​
    

Step 6: Copying of Moodle Files and Configuring

​​Then, you will copy your Moodle files to the default root directory for web content. This allows your user to access Moodle with the server's IP address or domain name. Follow the commands below.

  1. ​​Copy Moodle files to var/www/HTML:

    ​​sudo cp -R /opt/moodle /var/www/html/
    

    Here you are copying the entire contents of the /opt/moodle directory, including all its subdirectories and files.

  2. ​​Create a directory for storing data files:

    ​​sudo mkdir /var/moodledata
    
  3. Grant Apache the necessary permissions to read and write:

    ​​sudo chown -R www-data /var/moodledata
    
  4. Grants users full read, write, and execute permissions:

    ​​sudo chmod -R 777 /var/moodledata
    

​​Step 7: Create and configure database

​​Now, you will create and configure your database where Moodle will store its data. Follow these steps.

  1. ​​Open the MySQL Prompt:
    ​​sudo mysql -u root -p
    
    Note that you'll be asked for your password in the next step. Keep in mind that the password you type won't be visible. Once logged in you’ll see a MySQL>​ prompt. Run the next command.
  2. Create a database:
    ​​CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    
  3. Create a user in the database:
    create user 'Username'@'localhost' IDENTIFIED BY 'Password';
    
    Ensure you change Username ​to your desired username and Password​ to your desired password.
  4. Grant access to the user access:

    GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'Username'@'localhost';
    

    Change the Username to the username you created above.

  5. Exit MySQL Prompt:

    ​​quit;
    

​​Step 8: Completing Installation on the browser

​​Access Moodle by opening your web browser and entering the IP address or domain name where it is uploaded. The installation process will start automatically and prompt you to set up the site.

  1. ​​​​Open your web browser.​​

  2. ​​In the address bar, type the IP address of your server where Moodle is hosted, followed by /moodle. The address would typically be: ​​http://your_server_ip_address/moodle Ensure to replace your_server_ip_address it with your actual server's IP address.

User-uploaded image: screencapture-summituniversity-edu-ng-moodle-install-php-2023-12-16-15_53_07.png

​​Choosing Language:

​​You will select your preferred language or just click the next button if your preferred language is English.

User-uploaded image: screencapture-summituniversity-edu-ng-moodle-install-php-2023-12-16-16_39_32.png

​​Confirm Path:

​​Check the data directory, ensuring it is set to /var/moodledata, and click the next button.

User-uploaded image: screencapture-summituniversity-edu-ng-moodle-install-php-2023-12-16-16_41_11.png

​​Choose database driver:

​​Click the next button.

User-uploaded image: screencapture-summituniversity-edu-ng-moodle-install-php-2023-12-16-16_42_16.png

Database settings:

​​You will type the database the user created and the password in stage 7 into the Database User and Database password field. Then click the next button.

User-uploaded image: screencapture-summituniversity-edu-ng-moodle-install-php-2023-12-16-16_46_10.png

Configuration Completed:

​​If you encounter an error stating that your Moodle directory is not writable, follow these steps to resolve the issue:

  1. ​​Repeat Step 1 to log back into the server.

  2. ​​Run the following command to make the Moodle directory writable:

    ​​sudo chmod -R 777 /var/www/html/moodle
    
  3. ​​Return to your browser and refresh the page.

  4. Click the Next button to continue with the configuration process.

User-uploaded image: screencapture-summituniversity-edu-ng-lms-admin-index-php-2023-12-15-11_44_08.png

Confirm Installation:

​​Click the Continue button.

User-uploaded image: screencapture-summituniversity-edu-ng-lms-admin-index-php-2023-12-15-12_19_36.png

Server checks:

​​Ensure that all server checks are successfully passed. The installation process will perform a series of checks to confirm that your server meets the requirements for Moodle.

  1. ​​Carefully review each test on the server checks screen.

  2. ​​ Verify that all tests show an "OK" status.

​​Once all server checks have passed, the "Continue" button will be displayed. Click the Continue button to proceed with the installation.

​​If any test does not pass, review the error message and click the link provided in front of it. You will be directed to a page for guidance; take the necessary steps to address the issue before clicking Continue .

User-uploaded image: 4.png

​​Admin account:

​​You will provide the essential details for an administrator (admin) account. The admin account has elevated privileges and is crucial for managing and configuring your Moodle site. Once you've completed the admin account setup, you'll have the necessary credentials to log in and manage your Moodle site effectively. Click the update profile button.

User-uploaded image: 5.png

​​Site home settings:

​​You will provide all necessary details, including the site name, description, and other relevant information. Click the save changes button.

​​Step 9: Complete Setup

As you finalize your Moodle setup, prioritize security with the following steps:

  1. Re-login to Your Server: Repeat Step 1 to log back into the server.

  2. Revoke Permissions:

    sudo chmod -R 0755 /var/www/html/moodle
    

    This command grants full permissions to the owner and reads and executes permissions to the group and others. By making this adjustment, you can enhance the security of your Moodle installation. This ensures that files can be accessed and executed by the relevant parties while still maintaining a secure environment.

​​Conclusion

​​In conclusion, Moodle is a great learning platform for personalized learning. By following these steps, you've unlocked a powerful e-learning platform for personalized online education.

​​Thank you for taking the time to read this tutorial on Moodle. If you have questions or suggestions, please feel free to share them in the comments below.

Resources

If you're interested in learning more about personalized learning with Moodle, remember to explore these amazing resources.

  • [Explore Moodle site] (https://moodle.com/solutions/lms/)
1
Subscribe to my newsletter

Read articles from Abdulrasheed Abdulsalam directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abdulrasheed Abdulsalam
Abdulrasheed Abdulsalam