How To Install Moodle on Debian 10

Install Moodle on Debian 10

In this tutorial, we will show you how to install Moodle on Debian 10. For those of you who didn’t know, Moodle is a free and open-source learning management system written in PHP and often deployed in Linux under Apache/Nginx web servers with PHP and MySQL/MariaDB database management system, also known as LAMP or LEMP stack.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Moodle on a Debian 10 (Buster).


  • A server running one of the following operating systems: Debian 10 (Buster).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Moodle on Debian 10 Buster

Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update

Step 2. Installing the LAMP stack.

A Debian 10 LAMP server is required. If you do not have LAMP installed, Please read our previous tutorial to install LAMP Server on Debian 10.

Step 3. Installing Moodle on Debian 10.

Now we download the latest Moodle package using the following command:

cd /var/www/html

Extract the downloaded file:

tar xzf moodle-3.10.3.tgz

Change the ownership and the permissions of the extracted Moodle directory with the following command:

chown -R www-data:www-data /var/www/html/moodle
chmod -R 775 /var/www/html/moodle

Next, create a data directory and set Moodle directory permissions:

mkdir /var/www/html/moodledata

Set ownership and permissions so that Apache can access the files:

chown www-data:www-data /var/www/html/moodledata
chmod 775 /var/www/html/moodledata

Step 4. Configuring MariaDB for Moodle.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:


Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, we will need to log in to the MariaDB console and create a database for Moodle. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Moodle installation:

MariaDB [(none)]> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON moodle.* TO 'moodle_user'@'localhost' IDENTIFIED BY 'your-strong-passwd';
MariaDB [(none)]> quit;

Once the database server is installed, open the configuration file:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Then, add the below lines under  [mysqld] section:

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda
innodb_large_prefix = 1

Step 5. Configure Apache Web Server.

Now we create a new Apache virtual host for your domain name with the following content:

nano /etc/apache2/sites-available/

Add the following lines:

<VirtualHost *:80>
DocumentRoot /var/www/html/moodle

<Directory /var/www/html/moodle/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

Save the file and enable the virtual host with the following command:

sudo a2enmod rewrite
sudo a2ensite
sudo systemctl restart apache2

Step 6. Accessing Moodle Web Interface.

Moodle will be available on HTTP port 80 by default. Open your favorite browser and navigate to  and complete the required steps to finish the installation.

Install Moodle on Debian 10 Buster

Congratulations! You have successfully installed Moodle. Thanks for using this tutorial for installing the latest version of Moodle on the Debian system. For additional help or useful information, we recommend you check the official Moodle website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button