18 C
Texas
angeloma
Senior Writer and partner

How to Install Moodle on CentOS 7?

Thanks to the internet and computers in general, education is now better. In addition, it allows arriving in a faster way and of better quality. So, if you are a teacher or run an education center, then this post on how to install Moodle on CentOS 7 is ideal for you.

Moodle is a learning management system (LMS). It is quite popular in the world and is the main online learning tool for many educational institutions. It is written in PHP and supports several web servers such as Apache and Ngnix.

One of its main advantages is that it is open source and has a very active user and developer community that allows you to keep track of the development and its news.

So, let’s install Moodle on CentOS 7.

0. Prerequisites

- Advertisement -

Before starting you should do a few things so that there are no problems during the installation. First, install some necessary packages:

:~# yum install nano wget yum-utils

Next, disable SELinux:

:~# nano /etc/selinux/config

And change SELinux to disable:

0.- Disabling SELINUX
0.- Disabling SELinux

Finally, reboot the system.

1. Upgrade the system

First, you need to update the system. It is really simple to do and with this you guarantee to have the system with the security patches installed and working.

:~$ su
:~# yum update

1.- Upgrade the system
1.- Upgrade the system

Now, you can go on.

2. Install Apache Web server

As I said before, Moodle is compatible with several web servers, however, I will use Apache’s httpd. It’s a pretty well known server and it’s really easy to use.

To install it run this command.

:~# yum install httpd

2.- Installing Apache web server
2.- Installing Apache web server

Now, enable and start the service.

:~# systemctl enable httpd
:~# systemctl start httpd

3.- Enabling Apache web server service
3.- Enabling Apache web server service

Add the rule for the firewall.

:~# firewall-cmd --zone=public --add-service=http

And that’s all for Apache.

2. Install PHP

PHP is a programming language for web applications. Moodle is written in this fantastic language so you have to install it.

We only have one detail, the version that comes in the official CentOS 7 repositories is very old and Moodle requires something newer. So I will use an external repository to install PHP 7.1.

:~# yum install epel-release
:~# rpm -Uhv https://rpms.remirepo.net/enterprise/remi-release-7.rpm
:~# yum-config-manager --enable remi-php71

4.- Adding an external repository to install PHP 7.1
4.- Adding an external repository to install PHP 7.1

5.- Adding the external repository
5.- Adding the external repository

Then, install PHP 7.1

:~# yum install php php-common php-intl php-zip php-soap php-xmlrpc php-opcache php-mbstring php-gd php-curl php-mysql php-xml

6.- Install PHP 7.1
6.- Install PHP 7.1

So, restart Apache.

:~# systemctl restart httpd

PHP is correctly installed.

3. Install and configure MariaDB

The next step is to install and configure MariaDB. Moodle requires a database manager. In this case I will use MariaDB, an open source and easy to install MySQL fork.

:~# yum install mariadb mariadb-server

7.- Installing MariaDB
7.- Installing MariaDB

Now, you need to enable and start the service.

:~# systemctl enable mariadb
:~# systemctl start mariadb

8.- Working with MariaDB service
8.- Working with MariaDB service

Then, it is necessary to define the root password for MariaDB. This is easy to do thanks to the mysql_secure_installation script.

:~# mysql_secure_installation

9.- using mysql_secure_installation script
9.- using mysql_secure_installation script

In this section, you will be asked other questions concerning the configuration of MariaDB. These are the questions and so I have answered. So, you can do it as you wish. They are basic configurations.

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

So, the next step is to create the Moodle database.

:~# mysql -u root -p
CREATE DATABASE moodledb;
GRANT ALL PRIVILEGES ON moodledb.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'moodlepss';
FLUSH PRIVILEGES;
exit;

10.- Creating the database and user for Moodle
10.- Creating the database and user for Moodle

Finally, you need to edit the file /etc/my.cnf.d/server.cnf and add the following.

:~# yum install nano
:~# nano /etc/my.cnf.d/server.cnf
[client]
default-character-set = utf8mb4

[mysqld]
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
skip-character-set-client-handshake

[mysql]
default-character-set = utf8mb4

11.- Editing a MariaDB configuration file
11.- Editing a MariaDB configuration file

For these changes to take effect, restart MariaDB.

:~# systemctl restart mariadb

4.- Install Moodle

It’s finally time to install Moodle. First, you have to download it.

:~# cd /tmp/
:~# wget https://download.moodle.org/download.php/direct/stable35/moodle-latest-35.tgz -O moodle-latest.tgz

12.- Download and install Moodle
12.- Download and install Moodle

Then, decompress it.

:~# tar -xvzf moodle-latest.tgz

Next, move the created folder to /var/www/html.

:~# mv moodle /var/www/html/

Now it is necessary to change the owner of the folder. This to avoid permission problems.

:~# chown -R apache:apache /var/www/html/

13.- Changing the owner of the folder
13.- Changing the owner of the folder

5. Create a virtual host for Moodle

You need to create a virtual host for Moodle. It’s simple. Run this command and add the following.

:~# nano /etc/httpd/conf.d/moodle.conf

16.- Creating a virtual host for mooodle
14.- Creating a virtual host for moodle

Then, restart Apache.

:~# systemctl restart httpd

6. Complete the Moodle installation from CLI

Now is the time to complete the installation from CLI. To do this, run:

 :~# /usr/bin/php /var/www/html/moodle/admin/cli/install.php

15.- Completing the Moodle installation from CLI
15.- Completing the Moodle installation from CLI

During the execution of the script, you will first be asked for the language for the installation. The rest are database parameters and paths. See the images for reference.

15.- Completing the installation
16.- Completing the installation

Note: It is not mysqli. It is mariadb option on database driver.

You have also to set the admin account.

16.- Completing the installation
17.- Completing the installation

Finally, you will see this.

18.- Installation finished
18.- Installation finished

If you make a mistake, you can continue. In the end, you delete the /var/www/html/moodle/config.php file and run the installer again.

Next, give permission to the config file.

:~# chmod o+r /var/www/html/moodle/config.php

And restart apache.

:~# systemctl restart httpd

Now, go to your moodle directory on your web browser.

Next, log in. Go to http://your-domain/login.

21.- Moodle Log in page
19.- Moodle Login page

And finally, you will see this.

20.- Admin page
20.- Admin page

And that’s it.

Conclusion

Now that you know how to install Moodle you can start creating your own learning platforms.

One piece of advice I give you is to read through each step carefully.

Please share this article on your social networks.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article