This post assumes you already have apache, mysql, php, and phpmyadmin installed. If not then you can read this post here to do the installation which is a pre-requisiste if you want moodle installed properly.
Nevertheless, this post will touch on a few areas on the above where certain configurations are needed. However, overall it looks at the moodle open source content management system which is written and based on php. It allows educational institutions to create a very powerpul system for courses, students, and teachers. It’s used all across the world by many universities, and most importantly it’s free and released to the general public.
Step 1 – Minor Apache Configuration
In the previous post we left our html directory open to the general public. Hence, if someone new our IP address or landed on it and tried browsing what’s in our html directory they. So, we want to disable the directly listing for security purposes using the following command:
Next, run the commands below to stop, start and enable Apache2 service to always start up with the server boots.
Step 2 – Install PhP Related Module & Configure
In the previous post we installed PhP, however moodle needs certain modules that are required in order for it to function properly. We install them using the following command:
After install PHP, run the commands below to open PHP-FPM default file.
Then change the following lines below in the file and save (it’s a very long file, so you might want to search for the keywords and look for those in particular). You may increase the value to suite your environment.
Step 3 – Create Moodle database
Now that you’ve installed all the packages that are required, you are ready to start dealing with moodle. First run the commands below to create a blank Moodle database.
Run the commands below to logon to MySql database server:
Next, create a database, in this instance we’ll call it moodle but you can use anyname you prefer.
We will now create a database user. Here we are calling our user moodle user, with a new password. The new_password_here is where you put a password you like.
Your user needs full access to the database created and so we’ll grant full access.
Now save your changes, and exit.
Step 4: Download Moodle & Create Directories
At the time of this post moodle 3.7 was the latest version, I would suggest going to the moodle.org website and check what’s the latest and change the link from the command below. Here we’re downloading moodle in the temp folder, extracting it and moving to the html directory. We’re also ensuring the permissions are properly set. Moreover, please note for security purposes the moodledata folder should never be placed in your html folder.
cd /tmp/ && wget https://download.moodle.org/download.php/stable37/moodle-3.7.tgz
tar -zxvf moodle-latest-33.tgz
sudo mv moodle /var/www/html/moodle
sudo mkdir /var/moodledata
sudo chown -R www-data:www-data /var/www/html/moodle/
sudo chmod -R 755 /var/www/html/moodle/
sudo chown www-data /var/moodledata/
sudo chmod -R 755 /var/moodledata/
Step 5: Configure Apache2
Finally, configure Apahce2 site configuration file for Moodle. This file will control how users access Moodle content. Run the commands below to create a new configuration file called moodle.conf
Now copy and paste the content below into the file and save it. Replace the domain example.com with the domain you are gonig to be using.
VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/moodle/ ServerName example.com ServerAlias www.example.com <Directory /var/www/html/moodle/> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
After configuring the VirtualHost above, enable it by running the commands below, and then restarting apache as follows:
Step 6: Finishing the Installation
Finally, we’re ready to start the moodle installation process. Go to your domain that you set in your virtual host in the step above, for instance in ours it was example.com. You should be prompted with the first screenshot below. The screenshots below consist of certain steps that are to be taken. Screenshot 2 should have had the example.com on the web address, and the moodle directory should have been var/www/html/moodle , it just shows different since another different route was taken here. If you feel the installation is taking long, please wait! Depending on your connection it may take a while.









That’s it! Hope you have fun using moodle – sharing is caring!