Installation of Moodle on Ubuntu 14.04

Share this post on:

Moodle is a widely used open-source learning management system (LMS) that helps educators build engaging online learning environments. This guide walks you through installing Moodle on a modern Ubuntu server using Apache, MariaDB/MySQL, and PHP.

Update System Packages

Before you begin, refresh the repository and upgrade your system:

sudo apt update && sudo apt upgrade -y

Install Apache, Database, and PHP

Install the necessary packages for Moodle:

sudo apt install apache2 mariadb-server mariadb-client php libapache2-mod-php -y

Next, install PHP extensions required by Moodle:

sudo apt install graphviz aspell ghostscript php-curl php-gd php-intl php-mbstring php-xml php-xmlrpc php-soap php-zip php-mysql php-bcmath php-ldap git -y

Restart Apache:

sudo systemctl restart apache2

Set Up the Moodle Database

Secure your MariaDB installation (set root password, remove test DB, etc.):

sudo mysql_secure_installation

Then log into the MariaDB shell:

sudo mysql -u root -p

Create the Moodle database and user:

sqlCREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download Moodle

Change to a suitable directory and clone Moodle from the official Git repository:

cd /opt
sudo git clone git://git.moodle.org/moodle.git
cd moodle
sudo git branch -a
sudo git branch --track MOODLE_404_STABLE origin/MOODLE_404_STABLE
sudo git checkout MOODLE_404_STABLE

(You can choose a different branch — check Moodle branches for the latest version.)

Deploy Moodle Files

Copy the Moodle directory to the web root:

bashsudo cp -R /opt/moodle /var/www/html/

Create the Moodle data directory (outside web root for better security):

bashsudo mkdir /var/moodledata
sudo chown -R www-data:www-data /var/moodledata
sudo chmod -R 770 /var/moodledata

Set correct permissions for the Moodle application:

bashsudo chown -R www-data:www-data /var/www/html/moodle
sudo chmod -R 755 /var/www/html/moodle

Configure Apache for Moodle

Create a new virtual host configuration file:

sudo nano /etc/apache2/sites-available/moodle.conf

Add the following content:

text<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/moodle
    <Directory /var/www/html/moodle>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/moodle_error.log
    CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined
</VirtualHost>

Enable the site and required Apache modules:

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

Run the Moodle Installer

Now, open your browser and visit:

texthttp://localhost/moodle

The setup wizard will guide you through selecting the language, configuring the database, and creating an admin account.

When installation completes, double-check permissions to lock down the site:

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

Conclusion

Your Moodle installation is now ready to use! You can access the admin dashboard, install plugins, and start building online courses. For production servers, consider setting up HTTPS with Let’s Encrypt and tuning PHP/Apache for performance.

Share this post on:

Author: Rupinder Singh

I am a tireless intelligence seeker, coincidentally I am a computer guy too, who is passionate about Information Tools and Open-Source software. I Read Books, play Computer Games, Climb Mountains, when I am not changing the code.

View all posts by Rupinder Singh >

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.