Tuesday, February 2, 2021

Cara Install Moodle di CentOS 8 dengan NGINX dan MySQL

Pada tutorial kali ini kita akan menginstall Moodle di CentOS 8. Yang akan kita gunakan disini adalah LEMP, Linux, Nginx, MySQL dan PHP. Disini silakan siapkan dengan CentOS 8 yang siap pakai, dengan RAM minimal 512MB dan diskspace sekitar 5GB-an.


Silakan install stack LEMP terlebih dulu:


dnf install php-common php-iconv php-curl php-mbstring php-xmlrpc php-soap php-zip php-gd php-xml php-intl php-json libpcre3 libpcre3-dev graphviz aspell ghostscript clamav mysql
kemudian login ke mysql dan create database untuk Moodle:
mysql -u root -p
MariaDB [(none)]> CREATE DATABASE moodledb;
MariaDB [(none)]> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodledb.* TO 'moodleadmin'@'localhost' IDENTIFIED BY '[email protected]';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit
setelah itu kita pergi ke Moodle dan download dari sana https://download.moodle.org/.
# wget -c https://download.moodle.org/download.php/direct/stable39/moodle-latest-39.tgz
# tar -xzvf  moodle-latest-39.tgz
# mv moodle /var/www/html/
# chmod 775 -R /var/www/html/moodle
# chown nginx:nginx -R /var/www/html/moodle
kemudian kita perlu menyiapkan folder data untuk Moodle,
# mkdir -p /var/www/html/moodledata
# chmod 770 -R /var/www/html/moodledata
# chown :nginx -R /var/www/html/moodledata
edit file config.php:
# cd /var/www/html/moodle/
# cp config-dist.php config.php
# vim config.php
ubah:
$CFG->dbtype    = 'mariadb';      // 'pgsql', 'mariadb', 'mysqli', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native';     // 'native' only at the moment
$CFG->dbhost    = 'localhost';  // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname    = 'moodledb';     // database name, eg moodle
$CFG->dbuser    = 'moodleadmin';   // your database username
$CFG->dbpass    = '[email protected]zzwd0L2';   // your database password
$CFG->prefix    = 'mdl_';       // prefix to use for all table names
dan juga ganti variable wwwroot dan dataroot:
$CFG->wwwroot   = 'http://learning.web.id';
$CFG->dataroot  = '/var/www/html/moodledata';
jangan gembira dulu, kita harus bikin vhost NGINX untuk moodle, misal di file:
/etc/nginx/conf.d/moodle.conf
dengan isi:
server{
   listen 80;
    server_name learning.testprojects.me;
    root        /var/www/html/moodle;
    index       index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^(.+\.php)(.*)$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_index           index.php;
        fastcgi_pass            php-fpm;
        include                 /etc/nginx/mime.types;
        include                 fastcgi_params;
        fastcgi_param           PATH_INFO       $fastcgi_path_info;
        fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
kemudian test config NGINX tersebut dan restart nginx serta php-fpm:
# nginx -t
# systemctl restart nginx
# systemctl restart php-fpm
setelah itu lanjutkan dengan membuka browser dan buka URL wwwroot kita. lanjutkan instalasi lewat browser sampai selesai.

0 comments:

Post a Comment