Cara Install Moodle dengan Apache di FreeBSD
Tutorial FreeBSD server kali ini, kita akan belajar bagaimana cara install Moodle dengan menggunakan Apache web server disertai SSL dari Let’s Encrypt untuk protokol HTTPS.
Perangkat yang digunakan
Perangkat yang digunakan di tutorial ini:
- VPS FreeBSD 12.1 di Vultr
- Subdomain moodle.musaamin.my.id
- IP 207.148.123.152
- Apache
- PHP 7.4
- MariaDB 10.5
- Let’s Encrypt
- Moodle 3.10
Install Apache
Install Apache web server.
1 | pkg install apache24 |
Aktifkan service apache24.
1 | sysrc apache24_enable="YES" |
Jalankan service apache24.
1 | service apache24 start |
Browse http://serverIP untuk menguji apakah Apache web server sudah berjalan dengan baik.
Konfigurasi VirtualHost
Selanjutnya mengkonfigurasi virtualhost untuk subdomain moodle.musaamin.my.id.
Membuat folder untuk document root.
1 2 3 | mkdir -p /var/www/moodle.musaamin.my.id/public_html mkdir /var/www/moodle.musaamin.my.id/moodledata echo "hello world" > /var/www/moodle.musaamin.my.id/public_html/index.html |
Membuat folder untuk menyimpan file konfigurasi virtual host.
1 | mkdir /usr/local/etc/apache24/vhosts |
Membuat folder untuk log Apache.
1 | mkdir /var/log/apache |
Membuat file konfigurasi virtual host.
1 | nano /usr/local/etc/apache24/vhosts/moodle.musaamin.my.id.conf |
Isi file konfigurasi virtual hosts.
1 2 3 4 5 6 7 8 9 10 11 12 | <VirtualHost *:80> DocumentRoot /var/www/moodle.musaamin.my.id/public_html ServerName moodle.musaamin.my.id ErrorLog /var/log/apache/moodle.musaamin.my.id_error.log CustomLog /var/log/apache/moodle.musaamin.my.id_access.log common <Directory /var/www/moodle.musaamin.my.id/public_html> Order allow,deny Allow from all Require all granted AllowOverride All </Directory> </VirtualHost> |
Buka file konfigurasi Apache.
1 | nano /usr/local/etc/apache24/httpd.conf |
Aktifkan opsi ServerName dan masukkan server IP address.
1 | ServerName 207.148.123.152 |
Tambahkan di baris paling bawah.
1 | Include etc/apache24/vhosts/*.conf |
Cek apakah ada kesalahan konfigurasi.
1 | apachectl -t |
Jika tidak ada kesalahan.
1 | Syntax OK |
Restart service Apache.
1 | service apache24 restart |
Browse http://moodle.musaamin.my.id.
Install PHP
Install PHP 7.4 dan extensionnya.
1 | pkg install mod_php74 php74 php74-mysqli php74-curl php74-ctype php74-dom php74-fileinfo php74-filter php74-gd php74-iconv php74-intl php74-json php74-mbstring php74-opcache php74-openssl php74-session php74-simplexml php74-soap php74-tokenizer php74-xml php74-xmlreader php74-xmlrpc php74-zip php74-zlib |
Buat file konfigurasi untuk menghubungkan Apache dengan PHP.
1 | nano /usr/local/etc/apache24/Includes/php.conf |
Isi file php.conf.
1 2 3 4 5 6 7 8 9 | <IfModule dir_module> DirectoryIndex index.php index.html <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> </IfModule> |
Buat file php.ini
1 2 | cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini-production.default ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini |
Restart service Apache.
1 | service apache24 restart |
Buat file info.php.
1 | echo "<?php phpinfo(); ?>" > /var/www/moodle.musaamin.my.id/public_html/info.php |
Browse http://moodle.musaamin.my.id/info.php
Install SSL Let’s Encrypt
Buka file konfigurasi Apache.
1 | nano /usr/local/etc/apache24/httpd.conf |
Aktifkan modul SSL dan rewrite.
1 2 | LoadModule ssl_module libexec/apache24/mod_ssl.so LoadModule rewrite_module libexec/apache24/mod_rewrite.so |
Restart service Apache.
1 | service apache24 restart |
Install certbot Let’s Encrypt.
1 | pkg install py37-certbot-apache |
Request SSL untuk subdomain moodle.musaamin.my.id.
1 | certbot --apache -d moodle.musaamin.my.id |
Browse https://moodle.musaamin.my.id.
Install MariaDB
Install MariaDB database.
1 | pkg install mariadb105-server mariadb105-client |
Aktifkan dan jalankan service MariaDB.
1 2 | sysrc mysql_enable="YES" service mysql-server start |
Amankan instalasi MariaDB.
1 | mysql_secure_installation |
Jawab pertanyaannya.
1 2 3 4 5 6 7 | Enter current password for root (enter for none): ENTER Switch to unix_socket authentication [Y/n] y Change the root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y |
Konfigurasi MariaDB.
1 | nano /usr/local/etc/mysql/conf.d/server.cnf |
Tambahkan konfigurasi di bawah [mysqld].
1 2 3 4 | default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda innodb_large_prefix = 1 |
Restart service MariaDB.
1 | service mysql-server restart |
Login MariaDB
1 | mysql |
Buat database untuk Moodle.
1 2 3 4 5 | CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'moodle'@'localhost' IDENTIFIED BY 'rahasia'; GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'localhost'; FLUSH PRIVILEGES; exit |
Install Moodle
Download Moodle.
1 2 | wget https://download.moodle.org/download.php/direct/stable310/moodle-latest-310.tgz tar xzvf moodle-latest-310.tgz |
Hapus file index.html dan info.php yang dibuat sebelumnya.
1 2 | rm -f /var/www/moodle.musaamin.my.id/public_html/info.php rm -f /var/www/moodle.musaamin.my.id/public_html/index.html |
Copy isi folder moodle.
1 | cp -Rfv moodle/* /var/www/moodle.musaamin.my.id/public_html |
Ubah ownership.
1 | chown -R www:www /var/www/moodle.musaamin.my.id |
Browse https://moodle.musaamin.my.id untuk install Moodle.
- Language = English. Next
- Cek Data directory = /var/www/moodle.musaamin.my.id/moodledata. Next
- Database driver = MariaDB (native/mariadb). Next
- Database host = 127.0.0.1, Database name = moodle, Database user = moodle, Database password = rahasia. Next
- Konfirmasi lisensi. Continue
- Pemeriksaan server environment. Continue
- Instalasi. Continue
- Masukkan New password, email. Update profile
- Masukkan Full site name, Short name, Front page summary. Save changes
Moodle telah selesai diinstall.
Gratis saldo $100 untuk pendaftaran akun baru di Vultr. Daftar sekarang
Selamat mencoba 🙂