• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Tuesday, May 13, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How to Install Moodle on CentOS 7

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
21
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Using a Different System?
  2. Prerequisites
  3. Step 1: Update the system
  4. Step 2: Install Apache
  5. Step 3: Install MariaDB 10.x
    1. 3.1 Build the MariaDB 10.1 YUM repo
    2. 3.2 Install MariaDB 10.1 using YUM
    3. 3.3 Start the MariaDB service and set it as running at system startup
    4. 3.4 Secure the installation of MariaDB
    5. 3.5 Create a MariaDB database for Moodle
  6. Step 4: Install PHP 7.1 and necessary PHP 7.1 extensions
  7. Step 5: Install Moodle 3.2.1
    1. 5.1 Prepare the Moodle program files
    2. 5.2 Setup a dedicated data directory for Moodle
    3. 5.3 Setup a virtual host for Moodle
    4. 5.4 Install Moodle from CLI
    5. 5.5 Modify permissions to /var/www/html/config.php
    6. 5.6 Setup a cron job
    7. 5.7 Restart Apache
    8. 5.8 Modify firewall rules in order to allow HTTP access
  8. Want to contribute?

Using a Different System?

  • How to Install Moodle 3.3.x on CentOS 7

Are we missing a guide for your target system? Request one, or submit your own!


Moodle is an open-source Learning Platform or course management system (CMS) – a free Open Source software package designed to help educators create effective online courses.

This tutorial will cover the process of installing Moodle 3.2.x on a CentOS 7 server.

Prerequisites

  • A CentOS 7 x64 server instance with at least 2GB of RAM (4GB or more recommended).
  • A sudo user.
  • The EPEL yum repository.

Step 1: Update the system

Log in to your server via SSH using the sudo user to install epel, update the system, and restart to apply the updates.

sudo yum install epel-release -y
sudo yum update -y && sudo shutdown -r now

Step 2: Install Apache

sudo yum install httpd -y

In production, you should remove the pre-set Apache welcome page:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

Prevent Apache from listing web directory files to visitors:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start the Apache service and enable it to auto-start on boot

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install MariaDB 10.x

Moodle stores all its data to a MySQL Database. MariaDB is a drop-in replacement for MySQL and we will be installing the latest stable version, MariaDB 10.1.

3.1 Build the MariaDB 10.1 YUM repo

In order to create the MariaDB 10.1 YUM repo file, copy the below code segment to your SSH terminal console and then press the Enter button:

cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list - created 2017-01-14 03:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

3.2 Install MariaDB 10.1 using YUM

sudo yum install MariaDB-server MariaDB-client -y

3.3 Start the MariaDB service and set it as running at system startup

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

3.4 Secure the installation of MariaDB

sudo /usr/bin/mysql_secure_installation

Answer questions as below, and make sure to use a strong MariaDB root password instead of the sample one showed beneath:

  • Enter current password for root (enter for none): Just press the Enter button
  • Set root password? [Y/n]: Y
  • New password: your-root-password
  • Re-enter new password: your-root-password
  • 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

3.5 Create a MariaDB database for Moodle

Log into the MySQL shell as root:

mysql -u root -p

Type the MariaDB root password you set earlier when prompted.

In the MySQL shell, create a database moodle, a database user moodleuser, the database user’s password yourpassword as follows.

Note: For security purposes, you should replace the sample password yourpassword mentioned above with your own ones.

CREATE DATABASE moodle DEFAULT CHARACTER SET UTF8 COLLATE utf8_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 4: Install PHP 7.1 and necessary PHP 7.1 extensions

PHP is also required by Moodle. In order to achieve better performance, you can install PHP 7.1 and several PHP 7.1 extensions as follows:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install mod_php71w php71w-common php71w-mbstring php71w-xmlrpc php71w-soap php71w-gd php71w-xml php71w-intl php71w-mysqlnd php71w-cli php71w-mcrypt php71w-ldap -y

Step 5: Install Moodle 3.2.1

5.1 Prepare the Moodle program files

At the time of writing, the latest stable release of Moodle is Moodle 3.2.1. Download and unzip the Moodle 3.2.1 archive as follows:

Note: You can always get the download URL of the latest stable release of Moodle from its official download page.

cd
wget https://download.moodle.org/download.php/direct/stable32/moodle-3.2.1.tgz
sudo tar -zxvf moodle-3.2.1.tgz -C /var/www/html
sudo chown -R root:root /var/www/html/moodle

5.2 Setup a dedicated data directory for Moodle

For security purposes, this data directory should be outside of the web root directory:

sudo mkdir /var/www/moodledata
sudo chown -R apache:apache /var/www/moodledata
sudo chmod -R 755 /var/www/moodledata

5.3 Setup a virtual host for Moodle

Note: Remember to replace the values of ServerAdmin, ServerName, ServerAlias, Errorlog, and CustomLog with your own ones.

cat <<EOF | sudo tee -a /etc/httpd/conf.d/moodle.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/moodle/
ServerName moodle.example.com
ServerAlias www.moodle.example.com
<Directory /var/www/html/moodle/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/moodle.example.com-error_log
CustomLog /var/log/httpd/moodle.example.com-access_log common
</VirtualHost>
EOF

5.4 Install Moodle from CLI

sudo /usr/bin/php /var/www/html/moodle/admin/cli/install.php

When prompted, provide necessary information according to the specific settings to your setup. Summary information are listed below:

== Choose a language ==
en - English (en)
? - Available language packs
type value, press Enter to use default value (en)
: en
-------------------------------------------------------------------------------
== Data directories permission ==
type value, press Enter to use default value (2777)
: 2777
-------------------------------------------------------------------------------
== Web address ==
type value
: http://203.0.113.1
-------------------------------------------------------------------------------
== Data directory ==
type value, press Enter to use default value (/var/www/html/moodledata)
: /var/www/moodledata
-------------------------------------------------------------------------------
== Choose database driver ==
 mysqli
 mariadb
type value, press Enter to use default value (mysqli)
: mariadb
-------------------------------------------------------------------------------
== Database host ==
type value, press Enter to use default value (localhost)
: localhost
-------------------------------------------------------------------------------
== Database name ==
type value, press Enter to use default value (moodle)
: moodle
-------------------------------------------------------------------------------
== Tables prefix ==
type value, press Enter to use default value (mdl_)
: mdl_
-------------------------------------------------------------------------------
== Database port ==
type value, press Enter to use default value ()
:
-------------------------------------------------------------------------------
== Unix socket ==
type value, press Enter to use default value ()
:
-------------------------------------------------------------------------------
== Database user ==
type value, press Enter to use default value (root)
: moodleuser
-------------------------------------------------------------------------------
== Database password ==
type value
: yourpassword
-------------------------------------------------------------------------------
== Full site name ==
type value
: MY Moodle Site
-------------------------------------------------------------------------------
== Short name for site (eg single word) ==
type value
: moodle
-------------------------------------------------------------------------------
== Admin account username ==
type value, press Enter to use default value (admin)
: admin
-------------------------------------------------------------------------------
== New admin user password ==
type value
: your-admin-password
-------------------------------------------------------------------------------
== New admin user email address ==
type value, press Enter to use default value ()
: [email protected]
-------------------------------------------------------------------------------
== Upgrade key (leave empty to not set it) ==
type value
:
-------------------------------------------------------------------------------
Have you read these conditions and understood them?
type y (means yes) or n (means no)
: y

5.5 Modify permissions to /var/www/html/config.php

Having Moodle successfully installed, you need to allow the apache user to read Moodle configurations by modifying the permissions to /var/www/html/config.php as below:

sudo chmod o+r /var/www/html/moodle/config.php

5.6 Setup a cron job

Additionally, you need to setup a cron job in order to keep Moodle running correctly:

sudo crontab -u apache -e

Populate the cron file with:

* * * * *    /usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null

Save and quit:

:wq!

5.7 Restart Apache

Restart Apache in order to apply all your modifications:

sudo systemctl restart httpd.service

5.8 Modify firewall rules in order to allow HTTP access

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Finally, point your web browser to http://203.0.113.1 to visit the Moodle website. Use the admin’s username and password you setup earlier to log in.

This concludes our tutorial. Thanks for reading.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

Installing Bolt CMS on FreeBSD 12

Next Post

Install Rancher on CentOS 7

Next Post

Install Rancher on CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet