Installing Moodle on Your Own Server

If you want full control, you can install Moodle on your server.

1. Prepare the Environment

  • Moodle requires a server with:
    • Operating System: Linux (Ubuntu, CentOS, etc.) or Windows.
    • Web Server: Apache or Nginx.
    • PHP: Version 8.0 or later.
    • Database: MySQL, MariaDB, or PostgreSQL.
  • Minimum Hardware Requirements:
    • CPU: 2 cores.
    • RAM: 4GB.
    • Storage: At least 20GB (depends on the number of users and content).

2. Download Moodle

3. Install Moodle

  1. Install Required Packages on the Server:
    • Install Apache, PHP, and MySQL/MariaDB:
      bash
      sudo apt update
      sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-xml php-gd php-intl php-zip php-curl php-soap php-mbstring
  2. Create a Database for Moodle:
    • Log in to MySQL:
      bash
      sudo mysql
    • Create the database and user:
      sql
      CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
      CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword';
      GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
      FLUSH PRIVILEGES;
      EXIT;
  3. Download and Extract Moodle:
    • Download Moodle:
      bash
      wget https://download.moodle.org/stable401/moodle-latest-401.tgz
    • Extract and move to the web directory:
      bash
      tar -xvzf moodle-latest-401.tgz
      sudo mv moodle /var/www/html/
  4. Set Permissions:
    • Create data directories:
      bash
      sudo mkdir /var/moodledata
      sudo chown -R www-data:www-data /var/www/html/moodle /var/moodledata
      sudo chmod -R 755 /var/www/html/moodle /var/moodledata
  5. Configure Apache:
    • Create a configuration file for Moodle:
      bash
      sudo nano /etc/apache2/sites-available/moodle.conf
    • Add the following content:
      bash
      <VirtualHost *:80>
      ServerAdmin [email protected]
      DocumentRoot /var/www/html/moodle
      ServerName yourdomain.com

      <Directory /var/www/html/moodle>
      Options +FollowSymlinks
      AllowOverride All
      </Directory>

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>

    • Enable the configuration:
      bash
      sudo a2ensite moodle.conf
      sudo a2enmod rewrite
      sudo systemctl restart apache2
  6. Complete Installation via Browser:
    • Open http://yourdomain.com in a browser.
    • Follow the on-screen instructions to complete the setup:
      • Choose a language.
      • Configure the database (use the database information created earlier).
      • Finish the installation.