Moodle installation on Ubuntu

Introduction

Moodle is an open-source learning management system (LMS) used to create and manage online learning platforms.

This guide explains how to install Moodle on a plain Ubuntu server using Apache, PHP-FPM, and MySQL. It covers the required packages, Apache and PHP-FPM configuration, Moodle installation from Git, MySQL database setup, and completion of the Moodle web installation.

Note: This guide uses older versions of Ubuntu, PHP 5, MySQL, and Moodle 3.1-era configuration. The commands and package names may need to be updated for modern Ubuntu and Moodle versions.

Prerequisites

Before starting the installation, make sure you have:

  • An Ubuntu server with root or sudo access.
  • Apache web server.
  • MySQL database server.
  • PHP-FPM.
  • Git.
  • A server IP address accessible through a web browser.
  • Basic knowledge of Linux commands.

Implementation

Step 1: Install Required Packages

Install Apache, MySQL, PHP, PHP-FPM, and the required Apache module:

apt-get install apache2 mysql-server php5 libapache2-mod-fastcgi php5-fpm

Install the additional dependencies required by Moodle:

apt-get install graphviz aspell php5-pspell php5-curl php5-gd php5-intl php5-mysql php5-xmlrpc php5-ldap git-core

Step 2: Configure PHP-FPM with Apache

Enable the required Apache proxy modules:

cp -p /etc/apache2/mods-available/proxy.* /etc/apache2/mods-enabled/
cp -p /etc/apache2/mods-available/proxy_fcgi.load /etc/apache2/mods-enabled/

Add the following configuration under the Apache VirtualHost:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1

Step 3: Configure PHP-FPM Listening Port

By default, PHP-FPM may listen through a Unix socket. Change it to listen on TCP port 9000.

Edit:

vi /etc/php5/fpm/pool.d/www.conf

Comment out:

listen = /var/run/php5-fpm.sock

Add:

listen = 127.0.0.1:9000

Step 4: Reload Apache

Reload Apache to apply the configuration:

/etc/init.d/apache2 reload

Moodle Installation

Step 5: Clone Moodle from Git

Move to the /opt directory:

cd /opt

Clone Moodle:

sudo git clone git://git.moodle.org/moodle.git

Change to the Moodle directory:

cd moodle

List the available Git branches:

sudo git branch -a

Track the required stable branch:

sudo git branch --track remotes/origin/MOODLE_31_STABLE origin/MOODLE_31_STABLE

Checkout the stable branch:

sudo git checkout MOODLE_31_STABLE

Step 6: Copy Moodle Files to Apache

Copy the Moodle files to the Apache document root:

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

Create the Moodle data directory:

sudo mkdir /var/moodledata

Set the ownership:

sudo chown -R www-data /var/moodledata

Set the required permissions:

sudo chmod -R 777 /var/moodledata

Set the Moodle directory permissions:

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

Reload Apache:

service apache2 reload

MySQL Setup

Step 7: Configure InnoDB

Edit the MySQL configuration file:

vi /etc/mysql/my.cnf

Under the [mysqld] section and Basic Settings, add:

default-storage-engine = innodb

Step 8: Restart MySQL

Restart the MySQL service:

service mysql restart

Step 9: Create the Moodle Database

Log in to the MySQL prompt:

mysql

Create the Moodle database:

CREATE DATABASE IF NOT EXISTS moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Step 10: Create the Moodle Database User

Create a database user and grant the required permissions:

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

Complete the Moodle Setup

Step 11: Set Directory Permissions

Set the permissions for the web directory:

chmod -R 777 /var/www/

Step 12: Open Moodle in the Browser

Open the following URL in your browser:

http://<IP address of your server>

The Moodle installation page should now be displayed.

Step 13: Configure the Moodle Database

During the Moodle installation process, select:

Database Type: mysqli

Enter the following database details:

Host server: localhost
Database: moodle
User: moodle_user
Password: passwordformoodle_user

For the table prefix, use:

mdl_

Continue with the installation and enter the required administrator login details.

Step 14: Restore the Installation Directory Permissions

After completing the installation, change the permissions of the web directory:

chmod -R 755 /var/www/html

Conclusion

Moodle can be installed on an Ubuntu server by configuring Apache, PHP-FPM, and MySQL and then deploying the Moodle application.

The installation process includes configuring PHP-FPM to communicate with Apache, installing Moodle from Git, creating the Moodle data directory, configuring the MySQL database, and completing the setup through the web interface.

For production environments, use currently supported Ubuntu, PHP, Moodle, and database versions and apply appropriate security permissions rather than using broad 777 permissions.

FAQs

1. What is Moodle?

Moodle is an open-source learning management system used to create and manage online courses, learning content, users, and assessments.

2. Which web server is used in this Moodle setup?

This setup uses Apache as the web server and PHP-FPM to process PHP applications.

3. Which database is used for Moodle?

The original setup uses MySQL with the InnoDB storage engine.

4. Where is Moodle data stored?

The Moodle application files are placed under:

/var/www/html/

The Moodle data directory is:

/var/moodledata

5. How can I access the Moodle installation?

After configuring Apache and completing the setup, access the server IP address through a browser:

http://<IP address of your server>
  • Setting Up an SSL Website in CentOS/Ubuntu Without a Control Panel – Learn how to configure SSL for a website hosted directly on a CentOS or Ubuntu server without using a hosting control panel.
    Read the article
  • How to Install FFmpeg on Ubuntu Server – Learn how to install FFmpeg on an Ubuntu server for processing and handling multimedia files.
    Read the article

Talk to our experts

Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team here.

admin

Writes about Cloud & AWS at Pheonix Solutions.

Leave a Reply

Scroll to Top