Cara Install Moodle dengan 2 VM (Web Server & Database Server)
Apr 12, 2026 333 views

Cara Install Moodle dengan 2 VM (Web Server & Database Server)

Pendahuluan

Moodle adalah platform e-learning yang digunakan untuk pembelajaran online. Pada tutorial ini, Moodle akan dipisah menjadi:

  • Web Server (Apache + PHP + Moodle) โ†’ 192.168.xx.2
  • Database Server (MariaDB) โ†’ 192.168.xx.3

๐Ÿ“Œ Tujuan:

  • Lebih aman
  • Lebih stabil
  • Sesuai standar deployment server

๐Ÿงฉ Arsitektur Jaringan

Pastikan kedua VM:

  • Satu jaringan (bridge / LAN)
  • Bisa saling ping

Tes:

ping 192.168.10.3
ping 192.168.10.4

๐Ÿ”ต BAGIAN 1 โ€” SETUP DATABASE SERVER (192.168.10.4)

1. Update Sistem

sudo apt update && sudo apt upgrade -y

2. Install MariaDB

sudo apt install mariadb-server -y

3. Secure MariaDB

sudo mysql_secure_installation

Gunakan pengaturan berikut:

  • Enter password โ†’ Enter
  • unix_socket โ†’ Y
  • Change root password โ†’ N
  • Remove anonymous โ†’ Y
  • Disallow remote root โ†’ Y
  • Remove test DB โ†’ Y
  • Reload โ†’ Y

4. Izinkan Akses dari Web Server

Edit konfigurasi:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Ubah:

bind-address = 0.0.0.0

Restart:

sudo systemctl restart mariadb

๐Ÿ“Œ Ini penting agar database bisa diakses dari VM lain


5. Buat Database Moodle

Masuk MariaDB:

sudo mariadb

Jalankan:

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE USER 'moodleuser'@'192.168.10.3' IDENTIFIED BY 'MoodlePass123!';

GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'192.168.10.3';

FLUSH PRIVILEGES;
EXIT;

6. Buka Firewall

sudo ufw allow 3306

๐ŸŸข BAGIAN 2 โ€” SETUP WEB SERVER (192.168.10.3)

1. Update Sistem

sudo apt update && sudo apt upgrade -y

2. Install Apache + PHP

sudo apt install apache2 php php-cli php-mysql php-xml php-curl php-zip php-mbstring php-intl php-soap php-gd php-ldap unzip git -y

3. Install Module PHP untuk Apache

sudo apt install libapache2-mod-php8.3 -y

Restart:

sudo systemctl restart apache2

4. Aktifkan Rewrite

sudo a2enmod rewrite
sudo systemctl restart apache2

5. Download Moodle (Fix error download)

Gunakan metode stabil:

cd /tmp
wget https://download.moodle.org/download.php/direct/stable405/moodle-latest-405.tgz

Extract:

tar -xvzf moodle-latest-405.tgz

Pindahkan:

sudo mv moodle /var/www/html/

6. Set Permission

sudo chown -R www-data:www-data /var/www/html/moodle
sudo chmod -R 755 /var/www/html/moodle

7. Buat Folder Data

sudo mkdir /var/moodledata
sudo chown www-data:www-data /var/moodledata
sudo chmod 777 /var/moodledata

๐Ÿ“Œ Folder ini wajib untuk penyimpanan file Moodle


๐Ÿ”ง BAGIAN 3 โ€” KONFIGURASI PHP

Edit:

sudo nano /etc/php/8.3/apache2/php.ini

Ubah:

cari menggunakan ctrl + w

max_input_vars = 10000

Restart:

sudo systemctl restart apache2

๐ŸŒ BAGIAN 4 โ€” KONFIGURASI APACHE

ubah config:

sudo nano /etc/apache2/sites-available/000-default.conf

dari:

DocumentRoot /var/www/html

menjadi:

DocumentRoot /var/www/html/moodle

Aktifkan:

sudo systemctl reload apache2

๐Ÿงช BAGIAN 5 โ€” TEST DATABASE (WAJIB)

Dari web server:

sudo apt install mariadb-client
mysql -u moodleuser -p -h 192.168.10.4

Masukkan password:

MoodlePass123!

โœ… Jika berhasil login โ†’ lanjut โŒ Jika gagal โ†’ perbaiki dulu (jangan lanjut)


๐ŸŒ BAGIAN 6 โ€” INSTALL MOODLE VIA WEB

Buka browser:

http://192.168.10.3

Isi Konfigurasi

Database:

  • Type: MariaDB
  • Host: 192.168.10.4
  • Database: moodle
  • User: moodleuser
  • Password: MoodlePass123!

Data Directory:

/var/moodledata

Klik Next โ†’ Continue โ†’ sampai selesai


Did you find this blog helpful?

found this blog helpful.