How to Install Moodle on CentOs 7 Using Git
Enjoying this content? Subscribe to the Channel!
Mastering Moodle: How to Install Moodle LMS on CentOS 7 Using Git
Welcome back to Darren’s Tech Tutorials! We’re diving deep into the world of open-source Learning Management Systems (LMS) today by tackling the powerhouse platform: Moodle!
If you’re looking to host an educational platform, a corporate training portal, or just a powerful community learning environment, Moodle is the gold standard. In this comprehensive guide, we’ll walk through the process of installing Moodle on a CentOS 7 server, leveraging the power and flexibility of Git for easy version control and maintenance.
Ready to roll up your sleeves? Let’s dive in!
Introduction: Why Moodle and Git?
Moodle is an incredibly robust platform, but setting it up requires precise configuration, especially when using a stable, enterprise-grade operating system like CentOS 7. Using Git to clone the Moodle repository ensures you always have access to the latest stable branch and makes future upgrades significantly simpler.
Before we begin: Don’t forget to grab your Free Linux Cheat Sheet to keep those commands handy: http://eepurl.com/dkRNM9
Prerequisites Check
This guide assumes you have already set up the core components necessary for a fully functioning web server on CentOS 7. If you haven’t completed these steps, please ensure the following are installed and configured:
- CentOS 7: Installed and updated.
- Apache (httpd): Installed and running.
- MariaDB: Installed, secured, and running.
If you need help with these foundations, check out our previous tutorials in this series!
Step 1: Install Core PHP and Git
Moodle is a PHP application, and while you likely installed some basic PHP during your Apache setup, we need to ensure the core package is present before installing any required extensions. We also need the Git version control system.
Execute the following commands:
sudo yum install php
sudo yum install git
Step 2: Download Moodle using Git
Now that Git is installed, we can clone the Moodle repository directly into our web root (/var/www/html/).
First, navigate to the web root directory:
cd /var/www/html/
Next, use the git clone command to download the Moodle source code. This places all files into a new subdirectory named moodle.
sudo git clone git://git.moodle.org/moodle.git
Move into the newly created Moodle directory:
cd moodle
Selecting the Stable Branch
To ensure we are running a stable, tested version (and not the bleeding edge master branch), we need to track and checkout a specific stable branch. In this example, we’ll use a Moodle 3.1 stable version as specified in the original tutorial path:
git branch -a
sudo git branch --track MOODLE_31_STABLE origin/MOODLE_31_STABLE
sudo git checkout MOODLE_31_STABLE
Step 3: Configure the Moodle Database
We must create a dedicated database and a specific user account for Moodle to interact with MariaDB. This is a crucial security step!
Log into your MariaDB server as the root user:
mysql -u root -p
Enter your MySQL root password. Then, execute the following commands inside the MariaDB prompt:
create database moodle;
grant all on moodle.* to 'moodleuser'@'localhost' identified by 'password123';
exit
Note: Always replace
'password123'with a strong, complex password in a production environment!
Step 4: Configure Moodle’s Data Directory and Permissions
Moodle requires a separate, non-web-accessible directory to store crucial data—like user uploaded files, sessions, and configuration files. We’ll place this in the /home directory for security and then adjust permissions so that Apache can read and write to it.
sudo mkdir /home/moodledata
Setting Ownership and SELinux Context
Since Apache is running as the apache user, it must own the data directory. We also need to configure the SELinux security context on CentOS 7 to allow the web server to write to this location.
sudo chown apache:apache -R /home/moodledata
sudo chcon --type httpd_sys_rw_content_t /home/moodledata
Step 5: Install Required PHP Extensions
Moodle relies on numerous specific PHP modules for features like graphics rendering, SOAP communication, database connectivity, and multilingual support. We need to install these now.
First, let’s ensure the MariaDB connector for PHP is installed:
sudo yum install php-mysqli
Next, install the comprehensive list of required modules:
sudo yum install php-gd php-dom php-xmlreader php-mbstring php-xmlrpc php-soap php-intl
Finalizing Web Server Configuration
Before we restart the server, let’s handle the necessary Apache and basic Moodle configuration placeholders:
# Edit the Apache configuration file (required for directory access rules)
sudo vi /etc/httpd/conf/httpd.conf
# Restart Apache to load new modules and config
sudo service httpd restart
sudo service httpd reload
# Placeholder for Moodle config file creation (usually generated via web installer, but may need manual setup)
sudo vi /var/www/html/moodle/config.php
Step 6: Optimize MariaDB Settings for Moodle Performance
For large Moodle deployments, especially those dealing with many files and rich content, optimizing the MariaDB storage engine is critical. We’ll set the InnoDB file format to Barracuda to enable better performance and larger prefix indexing.
Log back into MariaDB:
mysql -u root -p
use moodle;
Execute these global setting changes:
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_per_table=on;
SET GLOBAL innodb_large_prefix=on;
exit
What’s Next?
Congratulations! You have successfully downloaded Moodle using Git, configured the database, set up permissions, and installed all necessary dependencies on CentOS 7!
The final step is to open your web browser and navigate to your server’s IP address or domain name followed by /moodle (e.g., http://your_server_ip/moodle). This will launch the Moodle web installer, which will automatically complete the config.php file creation and perform the final database population using the credentials you created in Step 3.
We hope this tutorial gave you the confidence to launch your own robust LMS. Building powerful systems doesn’t have to be complicated when you have the right steps!
If this guide helped you conquer the Moodle installation, please hit that Like button, Subscribe for more comprehensive guides, and let us know in the comments what you plan to teach with your new Moodle setup! Happy hosting!