Moodle is a popular open-source eLearning platform that allows educators to create online courses and manage learning activities. In this guide, we will walk you through the steps to install Moodle on Rocky Linux 8. Whether you are deploying it on a local server or using a Windows VPS UK, this tutorial covers everything you need to get started.
Step 1: Update Your System
Before installing Moodle, make sure your system is up to date by running the following commands:
sudo dnf update -y
Keeping your system updated is crucial for security and performance, whether you're running it on a local machine or on a VPS Windows Servers platform.
Step 2: Install Apache, MariaDB, and PHP
Moodle requires a web server, database, and PHP to function. Install Apache, MariaDB, and PHP by running:
sudo dnf install httpd mariadb-server mariadb php php-mysqlnd php-xml php-mbstring php-intl php-json php-zip -y
Start and enable Apache and MariaDB services:
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
Step 3: Secure MariaDB Installation
Run the MariaDB security script to secure your database:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database.
Step 4: Create a Database for Moodle
Log in to MariaDB and create a database and user for Moodle:
sudo mysql -u root -p
Inside the MariaDB shell, run the following commands:
CREATE DATABASE moodle_db DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodle_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON moodle_db.* TO 'moodle_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace your_password
with a strong password of your choice.
Step 5: Download and Set Up Moodle
Navigate to the Apache web directory and download the latest version of Moodle:
cd /var/www/html
sudo wget https://download.moodle.org/stable39/moodle-latest-39.tgz
sudo tar -xvzf moodle-latest-39.tgz
sudo mv moodle /var/www/html/moodle
sudo mkdir /var/www/html/moodledata
sudo chown -R apache:apache /var/www/html/moodle /var/www/html/moodledata
sudo chmod -R 755 /var/www/html/moodle /var/www/html/moodledata
Step 6: Configure Apache for Moodle
Create a new Apache configuration file for Moodle:
sudo nano /etc/httpd/conf.d/moodle.conf
Add the following content to the file:
DocumentRoot /var/www/html/moodle
DirectoryIndex index.php
AllowOverride All
Require all granted
ErrorLog /var/log/httpd/moodle_error.log
CustomLog /var/log/httpd/moodle_access.log combined
Save and close the file. Restart Apache:
sudo systemctl restart httpd
Step 7: Complete Moodle Installation via Web Browser
Open a web browser and navigate to:
http:///moodle
Follow the on-screen instructions to complete the Moodle installation. When prompted, enter the database information you created earlier:
- Database name:
moodle_db
- Database user:
moodle_user
- Password:
your_password