Arch Linux BasedManjaro

How To Install Moodle on Manjaro

Install Moodle on Manjaro

Moodle stands as one of the most popular open-source learning management systems (LMS) worldwide, offering robust features for online education. Installing Moodle on Manjaro Linux combines the power of this flexible LMS with the user-friendly nature of Arch-based distributions. This comprehensive guide walks you through every step of the installation process, ensuring you can set up a fully functional Moodle environment on your Manjaro system.

Prerequisites and System Requirements

Before diving into the installation process, it’s essential to understand what your system needs to run Moodle effectively.

Hardware Requirements

For a smooth Moodle experience, your system should meet or exceed these specifications:

  • Processor: Minimum 1GHz, recommended 2GHz dual-core or better
  • Memory (RAM): Minimum 512MB, recommended 1GB for small implementations and 8GB+ for production environments
  • Disk Space: 200MB for Moodle code plus at least 5GB for content storage
  • Network: Reliable internet connection for updates and access

The hardware requirements vary based on your expected user load. For small implementations with fewer than 50 simultaneous users, modest hardware will suffice. Larger deployments supporting hundreds or thousands of users will require more robust resources and possibly separate database and web servers.

Software Prerequisites

Manjaro should be equipped with:

  • Web Server: Apache (preferred) or Nginx
  • Database: MariaDB (recommended) or PostgreSQL
  • PHP: Version 7.4 or higher with required extensions
  • Web Browser: Any modern browser for administration

Additionally, you’ll need:

  • Basic Linux command-line knowledge
  • Administrator (sudo) privileges on your Manjaro system
  • Understanding of basic web server concepts

Preparing Your Manjaro System

The first step involves preparing your system for the Moodle installation.

Updating Your System

Always start with a fully updated system. Open your terminal and execute:

sudo pacman -Syu

This command synchronizes your package databases and upgrades all installed packages to their latest versions.

Wait for the update process to complete before proceeding. This ensures compatibility and security for your upcoming installation.

Creating Necessary Directories

Next, we’ll set up the directory structure that Moodle requires:

sudo mkdir -p /srv/http/moodle
sudo mkdir -p /var/www/moodledata

The first directory will hold the Moodle application files, while the second will store course content, user uploads, and other data generated by Moodle.

Installing the LAMP Stack

Moodle runs on the LAMP stack-Linux, Apache, MariaDB, and PHP. Let’s install these components one by one.

Installing Apache Web Server

Apache serves as the foundation for hosting Moodle:

sudo pacman -S apache

After installation, start and enable the Apache service:

sudo systemctl start httpd
sudo systemctl enable httpd

This configures Apache to start automatically at system boot.

Installing MariaDB Database Server

MariaDB provides the database backend for Moodle:

sudo pacman -S mariadb

Initialize the MariaDB data directory:

sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start and enable the MariaDB service:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure your MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, remove the test database, and reload privileges.

Installing PHP and Required Extensions

Install PHP and the extensions required by Moodle:

sudo pacman -S php php-apache php-gd php-intl php-xml php-pgsql php-mbstring

These extensions provide support for graphics processing, internationalization, XML handling, database connectivity, and proper character encoding.

Configuring PHP for Moodle

Edit the PHP configuration file to optimize it for Moodle:

sudo nano /etc/php/php.ini

Make these changes to the file:

  1. Uncomment and modify these settings:
    memory_limit = 256M
    post_max_size = 80M
    upload_max_filesize = 80M
    max_execution_time = 600
  2. Uncomment the MySQL extensions:
    extension=mysqli
    extension=pdo_mysql

Save and close the file with Ctrl+O, Enter, then Ctrl+X.

Database Setup for Moodle

Now we’ll create a dedicated database and user for Moodle.

Creating the Moodle Database

Access the MariaDB shell:

sudo mysql -u root -p

Enter your MariaDB root password, then execute these SQL commands:

CREATE DATABASE moodledb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON moodledb.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_secure_password’ with a strong, unique password. Note these credentials as you’ll need them during the Moodle web installation process.

Downloading and Extracting Moodle

With our environment prepared, let’s obtain and install the Moodle software.

Downloading Moodle

Download the latest stable Moodle package:

cd /tmp
wget https://download.moodle.org/download.php/direct/stable39/moodle-latest-39.tgz

This fetches the latest 3.9 version of Moodle. Check the Moodle website for newer versions if available.

Extracting and Moving Files

Extract the Moodle archive and move it to the web server directory:

sudo tar xvf moodle-latest-39.tgz -C /srv/http/

Set proper ownership for the Moodle files:

sudo chown -R http:http /srv/http/moodle
sudo chown -R http:http /var/www/moodledata

This ensures the Apache web server (running as user ‘http’ on Manjaro) can access and modify these files.

Web Server Configuration

Now we’ll configure Apache to serve the Moodle application.

Configuring Apache for Moodle

Create a virtual host configuration file:

sudo nano /etc/httpd/conf/extra/moodle.conf

Add this content:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/srv/http/moodle"
    ServerName moodle.local
    
    <Directory "/srv/http/moodle">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog "/var/log/httpd/moodle-error.log"
    CustomLog "/var/log/httpd/moodle-access.log" combined
</VirtualHost>

Now include this configuration in Apache’s main configuration:

sudo nano /etc/httpd/conf/httpd.conf

Add this line at the end:

Include conf/extra/moodle.conf

Restart Apache to apply the changes:

sudo systemctl restart httpd

Add an entry to your hosts file to resolve the domain locally:

sudo nano /etc/hosts

Add this line:

127.0.0.1 moodle.local

This allows you to access your Moodle installation via the URL http://moodle.local.

Creating the Moodle Data Directory

The data directory stores all files uploaded to Moodle, including course materials, assignments, and user data.

Setting Up the Moodle Data Directory

We already created the directory, but let’s ensure its permissions are correct:

sudo chmod 0777 /var/www/moodledata

This permissive setting is temporary for the installation. We’ll lock down permissions after installation completes for security purposes.

Web-Based Installation Process

With all preparations complete, we can now run the Moodle web installer.

Starting the Installation Wizard

Open your web browser and navigate to:

http://moodle.local

The Moodle installation wizard will launch automatically. Follow these steps:

  1. Select language: Choose your preferred language and click “Next”
  2. Confirm paths: Verify the web address and Moodle directories
  3. Choose database driver: Select “Improved MySQL (mysqli)”
  4. Configure database: Enter the database details you created earlier:
    • Database host: localhost
    • Database name: moodledb
    • Database user: moodleuser
    • Database password: your_secure_password
    • Tables prefix: mdl_ (default)Install Moodle on Manjaro
  5. Accept the copyright notice
  6. Server checks: The installer will verify your server meets all requirements
  7. Install Moodle: Click to begin the installation process

The installer will create the database tables and set up your Moodle environment. This may take several minutes depending on your system performance.

Setting Up Administrator Account

After the database setup completes, you’ll need to configure:

  1. Site administrator account:
    • Username, password, email, and other details
    • This will be the primary admin account with full control of the system
  2. Site settings:
    • Site name
    • Site description
    • Site default language
    • Other configuration options

Once completed, your Moodle installation is ready to use.

Post-Installation Configuration

After successful installation, several additional configurations will optimize your Moodle environment.

Setting Up Cron Jobs

Moodle relies on scheduled tasks for many functions. Set up a cron job to run Moodle’s task scheduler:

sudo crontab -e

Add this line:

*/15 * * * * /usr/bin/php /srv/http/moodle/admin/cli/cron.php > /dev/null

This runs Moodle’s cron tasks every 15 minutes.

Configuring Email

To enable email notifications, edit Moodle’s config.php file:

sudo nano /srv/http/moodle/config.php

Add these lines before the closing PHP tag:

$CFG->smtphosts = 'smtp.example.com:25';
$CFG->smtpuser = 'youruser@example.com';
$CFG->smtppass = 'yourpassword';
$CFG->smtpsecure = 'tls';

Replace the example values with your SMTP server details.

Security Best Practices

Implementing proper security measures is crucial for any Moodle installation.

Securing File Permissions

After installation, tighten security by adjusting permissions:

sudo find /srv/http/moodle -type d -exec chmod 755 {} \;
sudo find /srv/http/moodle -type f -exec chmod 644 {} \;
sudo chmod 750 /var/www/moodledata
sudo chmod 750 /srv/http/moodle/config.php

These commands restrict permissions to only what’s necessary for operation.

Implementing SSL/TLS

For production environments, secure communications with SSL/TLS:

  1. Install SSL certificates (Let’s Encrypt is a free option)
  2. Configure Apache to use HTTPS
  3. Update your Moodle configuration to force secure connections

Installing Additional Plugins

Extend Moodle’s functionality with plugins tailored to your needs.

Finding and Installing Plugins

  1. Browse the official Moodle plugins directory.
  2. Download plugins compatible with your Moodle version
  3. Extract the plugin to the appropriate directory (usually /srv/http/moodle/mod/ for activity modules)
  4. Visit http://moodle.local/admin/index.php to complete the plugin installation
  5. Configure the plugin according to your requirements

Customizing Your Moodle Site

Personalize your Moodle installation to match your organization’s needs.

Theme Customization

  1. Access the Site Administration panel
  2. Navigate to Appearance > Themes
  3. Install additional themes or modify the current theme
  4. Customize colors, logos, and layouts to match your branding

Troubleshooting Common Issues

Even with careful installation, you might encounter issues. Here are solutions to common problems.

Database Connection Errors

If you see “Database connection failed” errors:

  1. Verify database credentials in config.php
  2. Ensure the MariaDB service is running
  3. Check that the moodleuser has proper permissions
  4. Confirm the database exists and is accessible

Performance Issues

If Moodle runs slowly:

  1. Enable caching in Site Administration > Plugins > Caching > Configuration
  2. Optimize PHP settings (increase memory_limit and max_execution_time)
  3. Consider database optimization with regular maintenance
  4. Upgrade hardware if necessary for larger installations

File Upload Problems

For “File too large” errors:

  1. Increase upload_max_filesize and post_max_size in php.ini
  2. Restart Apache after making changes
  3. Check directory permissions on the moodledata directory

Backup and Maintenance

Implementing a robust backup strategy prevents data loss and facilitates recovery.

Automated Backups

Configure regular backups:

  1. Access Site Administration > Courses > Backups
  2. Set up automated course backups
  3. Schedule system-level backups of the database and moodledata directory:
sudo nano /etc/cron.daily/moodle-backup

Add a script to back up both the database and files:

#!/bin/bash
BACKUP_DIR="/var/backups/moodle"
DATE=$(date +%Y-%m-%d)
mkdir -p $BACKUP_DIR
mysqldump -u moodleuser -p'your_secure_password' moodledb > $BACKUP_DIR/moodle-db-$DATE.sql
tar -czf $BACKUP_DIR/moodledata-$DATE.tar.gz /var/www/moodledata

Make the script executable:

sudo chmod +x /etc/cron.daily/moodle-backup

This ensures daily backups of your crucial Moodle data.

Congratulations! You have successfully installed Moodle. Thanks for using this tutorial for installing Moodle Learning Platform or course management system on Manjaro Linux system. For additional help or useful information, we recommend you check the official Moodle website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button