How to setup moodle on CentOS 8
Enjoying this content? Subscribe to the Channel!
Master Moodle Installation: Step-by-Step Guide for CentOS 8 and RHEL 8 (Moodle 3.11)
Welcome back to Darren’s Tech Tutorials!
If you’re looking to deploy a robust, open-source Learning Management System (LMS) on a stable enterprise platform, you’ve come to the right place. Moodle is the world’s leading customizable learning platform, and today, we’re making it production-ready on your CentOS 8 or Red Hat 8 Linux server.
This comprehensive guide, based on our popular video tutorial, walks you through the entire process, ensuring you install Moodle version 3.11 successfully. We’ll handle all the critical prerequisites—Apache, MariaDB, and PHP—before downloading and configuring the Moodle system itself.
Let’s dive into setting up your new LMS!
Setting the Stage: Essential Prerequisites
Before we install Moodle, we need a functioning LAMP stack (Linux, Apache, MariaDB, PHP). Moodle relies heavily on these services to handle web traffic, store user data, and process code.
Note: All commands referenced in this guide can be copied directly from the original source documentation here: https://darrenoneill.eu/?p=4729
Installing and Configuring Apache (The Web Server)
Apache is the engine that serves Moodle content to your users. We need to install the HTTP daemon (httpd), enable it, and ensure our server firewall allows traffic.
- Install Apache: Use your package manager to install the web server package.
- Start and Enable Service: Ensure Apache starts automatically upon boot and is running now.
- Configure the Firewall:
Since CentOS 8 and RHEL 8 use
firewalld, we must open ports 80 (HTTP) and optionally 443 (HTTPS) to allow external access.
Key Action: Once installed, always double-check that your server is accessible via its IP address or domain name in a web browser.
Database Setup with MariaDB
Moodle requires a relational database to store crucial information like course structures, user profiles, and activity logs. We use MariaDB, a high-performance drop-in replacement for MySQL.
- Install MariaDB Server: Install the MariaDB server package.
- Start and Enable Service: Get the database service running immediately.
- Run the Security Script:
It is vital to run the security installation script (
mysql_secure_installation) to set the root password, remove anonymous users, and disable remote root login. - Create the Moodle Database and User:
Log into the MariaDB shell and execute the following commands (substituting your preferred database name, username, and password):
- Create the database (e.g.,
moodle_db). - Create a dedicated user (e.g.,
moodle_user) that Moodle will use to connect. - Grant the necessary privileges to this user on the new database.
- Create the database (e.g.,
Installing PHP and Required Extensions
Moodle 3.11 requires PHP to operate, along with numerous specialized extensions to handle tasks like image manipulation, internationalization, and database connectivity.
- Install PHP: Install the base PHP package.
- Install Required PHP Extensions:
This is the most critical step for Moodle compatibility. You must install necessary modules such as:
php-mysqlnd,php-gd,php-intl,php-xmlrpc,php-zip,php-soap, and others listed in the commands link. - Adjust PHP Settings (Optimization):
Moodle works best when you increase common limits in the
php.inifile, specifically:memory_limit(e.g., 256M or 512M)upload_max_filesizepost_max_sizemax_execution_time
- Restart Apache: After making changes to PHP configurations, always restart the Apache service so the changes take effect.
Downloading and Preparing Moodle
With the LAMP stack ready, it’s time to grab the Moodle software and place it where the web server can access it.
- Download Moodle:
Use
wgetto download the latest stable Moodle 3.11 archive directly from the Moodle download page. - Extract the Files:
Unzip the archive and move the contents into the Apache document root, typically
/var/www/html/moodle. - Create the Data Directory:
Moodle needs a dedicated directory to store non-web-accessible files (uploaded assignments, cache data, etc.). Create this directory outside of the web root for security (e.g.,
/var/moodledata). - Set Permissions and Ownership:
The web server user (
apacheon CentOS/RHEL) must have read and write permissions to both the Moodle installation directory and themoodledatadirectory. Change the ownership recursively usingchown.
Running the Moodle Installation Wizard
You’ve installed all the components! The final step is running the web-based installation wizard to connect Moodle to the database and finalize configurations.
- Access the Wizard:
Open your web browser and navigate to the Moodle installation path (e.g.,
http://your_server_ip/moodle). - Language and Paths: Select your language and confirm the web and data directory paths are correct.
- Database Connection:
Enter the database credentials you set up earlier:
- Database driver (MariaDB/MySQL)
- Database name (
moodle_db) - Database user (
moodle_user) - Password
- License and Checks: Moodle will run a crucial environment check. If you followed the PHP extension steps correctly, you should see green check marks across the board.
- Finalize Setup: The wizard will complete the table creation process. You will then be prompted to set up the primary administrative account, configure site details (site name, description), and finalize the installation.
Conclusion
Congratulations! You have successfully deployed a robust Moodle 3.11 Learning Management System on your CentOS 8 or RHEL 8 server. You now have a powerful platform ready to host educational content, manage courses, and facilitate online learning.
This is a fantastic achievement for any system administrator. We encourage you to jump in, customize your new Moodle instance, and start building your first course!
If this tutorial helped you get Moodle running smoothly, please give the video a like and hit that subscribe button for more in-depth, practical tech guides from Darren’s Tech Tutorials. See you in the next one!