Install Moodle on Red Hat Enterprise Linux 8 - Step by Step Process ?

Moodle is an open-source digital learning solution for creating dynamic teaching and learning environments.

Moodle is written in PHP, and it powers numerous learning platforms worldwide. You can download and install the Moodle software on your own web server, or let a Moodle Partner handle the hosting and implementation for you.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to install Moodle on any Linux Distribution.
In this context, we shall look into how to download and install Moodle on your own Apache web server running on Red Hat Enterprise Linux 8 (RHEL 8).

How to Install Moodle on Red Hat Enterprise Linux ?

To begin, you need to have LAMP stack installed on RHEL 8 and ensure that all commands is performed by user with sudo privileges.
Then follow the steps given below.

1. Prepare Apache for Moodle

If you would like to use Moodle with your own registered domain name, then it is recommended to create a virtual host on Apache as follows.
Open the Apache main configuration file:

$ sudo nano /etc/httpd/conf/httpd.conf

Scroll down to the bottom of the file and then append the following configuration directives:

# Virtual Hosts

<VirtualHost *:80>

DocumentRoot "/var/www/linuxapt.com/"

ServerName linuxapt.com

CustomLog /var/log/httpd/linuxapt.com_access.log combined

ErrorLog /var/log/httpd/linuxapt.com_error.log

</VirtualHost>

Note: Replace linuxapt with your own domain name. Also, ensure that the DNS A record for your domain is pointing to the IP address of your Apache web server.
Save changes and close the httpd.conf file.
Next, run the following command to create the DocumentRoot directory where your Moodle website content will be stored:

$ sudo mkdir /var/www/linuxapt.com


2. Prepare PHP for Moodle

Moodle requires some PHP extensions without which the installation will not complete.

$ sudo dnf install php-json php-xml php-mysqlnd php-mbstring php-zip php-gd php-intl


3. Download Moodle

i. As of this posting, Moodle 3.10.3+ is the latest version available on the official download page:

$ sudo wget https://download.moodle.org/download.php/direct/stable310/moodle-latest-310.tgz

ii. Run the next command to extract the downloaded Moodle archive and place the contents in your website's document root.
Do remember to replace linuxapt.com accordingly:

$ sudo tar -xvf moodle-latest-310.tgz -C /var/www/linuxapt.com

You should now have a folder named moodle under the /var/www/yourdomain directory.
iii. Now, you need to change the ownership of the Moodle DocumentRoot directory to the default Apache service account.
For instance:

$ sudo chown -R apache:apache /var/www/linuxapt.com

iv. Further, change the permissions on the Moodle DocumentRoot directory.

$ sudo chmod -R 755 /var/www/linuxapt.com

v. Next, Moodle needs a data directory for storing files that are uploaded by users.
This directory should not be accessible to the public.

$ sudo mkdir /var/moodledata

vi. Change ownership of the Moodle data directory to the default Apache service account as follows.

$ sudo chown -R apache:apache /var/moodledata

vii. Also, change the permissions on the Moodle data directory as follows.

$ sudo chmod -R 755 /var/moodledata


4. Prepare MariaDB for Moodle

Moodle requires a database for storing application data such as user details, site information, course details, and so on.
i. Login to MariaDB with the command below:

$ sudo mysql -u root -p

Once logged in, you should see the MariaDB [(none)]> prompt.
ii. Now, create a database for Moodle as follows:

MariaDB [(none)]> CREATE DATABASE moodle;

iii. Next, create a database user. Replace moodleuser and moodlepass accordingly.

MariaDB [(none)]> CREATE USER 'moodledb'@'localhost' IDENTIFIED BY 'moodlepass';

iv. After that, run the query below to grant all privileges on the moodle database to moodleuser:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON moodle.* TO 'moodledb'@'localhost';

v. Update the grant tables to save your changes:

MariaDB [(none)]> FLUSH PRIVILEGES;

vi. Quit MariaDB:

MariaDB [(none)]> QUIT;


5. Configure Moodle

i. First, change into the previously extracted moodle folder.
For example:

$ cd /var/www/linuxapt.com/moodle

ii. And then create the main Moodle configuration file (config.php) from the sample configuration file (config-dist.php) as follows.

$ sudo cp config-dist.php config.php

iii. Edit the config.php Moodle configuration file.

$ sudo nano config.php

In the Moodle configuration file, locate the DATABASE SETUP section, and change the default values for dbtype, dbname, dbuser, and dbpass.
Scroll down until you see WEB SITE LOCATION. Change 'http://example.com/moodle' to 'http://yoursite.com/moodle' accordingly.
This is where users will go to access your Moodle website.
Scroll down further until you see DATA FILES. Change '/home/example/moodledata' to the moodle data directory path which you created earlier.
That is, '/var/moodledata'
iv. Save changes and close the Moodle configuration file.

6. Install Moodle

i. Open a web browser and go yourdomain.com/moodle/admin to complete the installation of Moodle.
In our case, going to linuxapt.com/moodle/admin takes me to the Moodle installation page.
ii. Click Continue to proceed. On the next page, server checks might report some missing PHP extensions.
As long as nothing is highlighted in red here, you are good to go.
Otherwise, read the instructions next to any required extensions which are highlighted in red to resolve the issues.
iii. Also, at the bottom of the page, there is a message indicating that my server meets all requirements, and we can therefore click Continue to proceed.
iv. After you click Continue, wait for the Moodle installation to complete. You would see a series of success messages as the installation progresses.
Do not leave the installation page.
v. Once done, click Continue at the bottom of the page.
vi. On the next page, you would be required to create your main Moodle admin account.
Provide the required information and click Update Profile.
vii. Follow the instructions on the next page to configure your site name, front page summary, etc.
viii. After completing the installation process, users can visit yourdomain.com/moodle in a web browser to access your Moodle website.

[Need urgent assistance in fixing Ubuntu Linux related issues? We can help you. ]

This article covers how to download, configure, and install Moodle powered by the LAMP stack on RHEL 8.

Moodle is the world’s most popular learning management system for building robust online learning sites.

How to open HTTP and HTTPS for Moodle Learning Platform in CentOS 8 ?
To open HTTP and HTTPS services in the firewall to allow traffic to the NGINX web server, run the commands below:

# firewall-cmd --permanent --zone=public --add-service=http 
# firewall-cmd --permanent --zone=public --add-service=https

# firewall-cmd --reload

Related Posts