Showing posts with label cron. Show all posts
Showing posts with label cron. Show all posts

Thursday, 23 April 2026

🚀 Install Moodle 🔥

 🔥 kita langsung gas install stack Moodle (LEMP: Nginx + MariaDB + PHP) yang stabil & ringan untuk server Guru.


🚀 1. Install semua paket sekaligus

apt install nginx mariadb-server php-fpm php-mysql php-xml php-gd php-curl php-zip php-intl php-mbstring php-soap php-bcmath php-cli php-opcache php-ldap php-imagick unzip git -y

🐘 2. Aktifkan service penting

systemctl enable nginx
systemctl enable mariadb
systemctl enable php8.2-fpm

systemctl start nginx
systemctl start mariadb
systemctl start php8.2-fpm

🔐 3. Amankan MariaDB

mysql_secure_installation

👉 Jawaban:

  • Set root password → YES

  • Remove anonymous → YES

  • Disallow root remote → YES

  • Remove test DB → YES


🧠 4. Buat database Moodle

Masuk MariaDB:

mysql -u root -p

Lalu:

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

👉 Ganti:

  • passwordku → password aman versi Guru


⚙️ 5. Setting PHP (WAJIB)

nano /etc/php/8.2/fpm/php.ini

Cari & ubah:

memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 100M
max_execution_time = 300

Simpan lalu:

systemctl restart php8.2-fpm

📁 6. Siapkan folder Moodle

mkdir -p /var/www/moodle
mkdir -p /var/moodledata

chown -R www-data:www-data /var/www/moodle
chown -R www-data:www-data /var/moodledata

chmod -R 755 /var/www/moodle
chmod -R 770 /var/moodledata

🌐 7. Config Nginx (siap pakai)

nano /etc/nginx/sites-available/moodle

Isi:

server {
    listen 80;
    server_name _;

    root /var/www/moodle;
    index index.php index.html;

    client_max_body_size 100M;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    location ~* \.(jpg|jpeg|png|gif|css|js|ico|svg)$ {
        expires max;
        log_not_found off;
    }
}

Aktifkan:

ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx

📦 8. Download Moodle

cd /var/www/
git clone -b MOODLE_405_STABLE git://git.moodle.org/moodle.git moodle

Set permission lagi:

chown -R www-data:www-data /var/www/moodle

⏰ 9. Setup cron Moodle

crontab -e

Isi:

* * * * * /usr/bin/php /var/www/moodle/admin/cli/cron.php >/dev/null

🌍 10. Akses Moodle

Buka browser:

👉 http://IP_SERVER


🎯 STATUS SEKARANG

Kalau semua benar:

  • Nginx ✅

  • PHP ✅

  • MariaDB ✅

  • Moodle siap install via web ✅


🚀 NEXT STEP

Nanti di browser:

  • pilih bahasa

  • isi database:

    • DB name: moodle

    • user: moodleuser

    • password: (yang dibuat tadi)



Wednesday, 4 June 2025

Membuat cron di server moodle

 $ sudo crontab -u www-data -e
sudo: crontab: command not found
 

utuhglobal@moodle-vm:~$ sudo apt update
Hit:1 http://us-central1.gce.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://us-central1.gce.archive.ubuntu.com/ubuntu jammy-updates InRelease     
Hit:3 http://us-central1.gce.archive.ubuntu.com/ubuntu jammy-backports InRelease   
Hit:4 https://packages.cloud.google.com/apt google-cloud-ops-agent-jammy-2 InRelease
Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease                   
Hit:5 https://dlm.mariadb.com/repo/mariadb-server/10.11/repo/ubuntu jammy InRelease
Hit:7 https://dlm.mariadb.com/repo/maxscale/latest/apt jammy InRelease             
Hit:9 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease     
Hit:8 https://downloads.mariadb.com/Tools/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
34 packages can be upgraded. Run 'apt list --upgradable' to see them.


utuhglobal@moodle-vm:~$ sudo apt install cron
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  anacron checksecurity default-mta | mail-transport-agent
The following NEW packages will be installed:
  cron
0 upgraded, 1 newly installed, 0 to remove and 34 not upgraded.
Need to get 73.7 kB of archives.
After this operation, 261 kB of additional disk space will be used.
Get:1 http://us-central1.gce.archive.ubuntu.com/ubuntu jammy/main amd64 cron amd64 3.0pl1-137ubuntu3 [73.7 kB]
Fetched 73.7 kB in 0s (2521 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package cron.
(Reading database ... 58521 files and directories currently installed.)
Preparing to unpack .../cron_3.0pl1-137ubuntu3_amd64.deb ...
Unpacking cron (3.0pl1-137ubuntu3) ...
Setting up cron (3.0pl1-137ubuntu3) ...
Adding group `crontab' (GID 121) ...
Done.
Created symlink /etc/systemd/system/multi-user.target.wants/cron.service → /lib/systemd/system/cron.service.
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Scanning processes...                                                               
Scanning linux images...                                                            

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.


utuhglobal@moodle-vm:~$ which crontab
/usr/bin/crontab
 

utuhglobal@moodle-vm:~$ dpkg -l | grep cron
ii  cron                             3.0pl1-137ubuntu3                       amd64        process scheduling daemon
 

utuhglobal@moodle-vm:~$ sudo crontab -u www-data -e
no crontab for www-data - using an empty one
crontab: installing new crontab

2. Tambahkan baris cron berikut

Di dalam file crontab yang terbuka, tambahkan baris ini:

*/1 * * * * /usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null 2>&1
 

Artinya: jalankan cron.php setiap 1 menit. Output diarahkan ke null agar tidak membanjiri log. 


utuhglobal@moodle-vm:~$ sudo tail -n 30 /var/log/syslog
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' resumed (module 'builtin:omfile') [v8.2112.0 try https://www.rsyslog.com/e/2359 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' suspended (module 'builtin:omfile'), retry 0. There should be messages before this one giving the reason for suspension. [v8.2112.0 try https://www.rsyslog.com/e/2007 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' resumed (module 'builtin:omfile') [v8.2112.0 try https://www.rsyslog.com/e/2359 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' suspended (module 'builtin:omfile'), retry 0. There should be messages before this one giving the reason for suspension. [v8.2112.0 try https://www.rsyslog.com/e/2007 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' resumed (module 'builtin:omfile') [v8.2112.0 try https://www.rsyslog.com/e/2359 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' suspended (module 'builtin:omfile'), retry 0. There should be messages before this one giving the reason for suspension. [v8.2112.0 try https://www.rsyslog.com/e/2007 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' resumed (module 'builtin:omfile') [v8.2112.0 try https://www.rsyslog.com/e/2359 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' suspended (module 'builtin:omfile'), retry 0. There should be messages before this one giving the reason for suspension. [v8.2112.0 try https://www.rsyslog.com/e/2007 ]
Jun  4 00:48:35 moodle-vm rsyslogd: action 'action-8-builtin:omfile' suspended (module 'builtin:omfile'), next retry is Wed Jun  4 00:49:05 2025, retry nbr 0. There should be messages before this one giving the reason for suspension. [v8.2112.0 try https://www.rsyslog.com/e/2007 ]
Jun  4 00:48:35 moodle-vm systemd[1]: Starting Update the local ESM caches...
Jun  4 00:48:35 moodle-vm systemd[1]: apt-news.service: Deactivated successfully.
Jun  4 00:48:35 moodle-vm systemd[1]: Finished Update APT News.
Jun  4 00:48:36 moodle-vm systemd[1]: esm-cache.service: Deactivated successfully.
Jun  4 00:48:36 moodle-vm systemd[1]: Finished Update the local ESM caches.
Jun  4 00:48:45 moodle-vm systemd[1]: Reloading.
Jun  4 00:48:45 moodle-vm systemd[1]: Configuration file /run/systemd/system/netplan-ovs-cleanup.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.
Jun  4 00:48:45 moodle-vm systemd[1]: /lib/systemd/system/snapd.service:23: Unknown key name 'RestartMode' in section 'Service', ignoring.
Jun  4 00:48:45 moodle-vm systemd[1]: Reloading.
Jun  4 00:48:45 moodle-vm systemd[1]: Configuration file /run/systemd/system/netplan-ovs-cleanup.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.
Jun  4 00:48:45 moodle-vm systemd[1]: /lib/systemd/system/snapd.service:23: Unknown key name 'RestartMode' in section 'Service', ignoring.
Jun  4 00:48:46 moodle-vm systemd[1]: Reloading.
Jun  4 00:48:46 moodle-vm systemd[1]: Configuration file /run/systemd/system/netplan-ovs-cleanup.service is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.
Jun  4 00:48:46 moodle-vm systemd[1]: /lib/systemd/system/snapd.service:23: Unknown key name 'RestartMode' in section 'Service', ignoring.
Jun  4 00:48:46 moodle-vm systemd[1]: Started Regular background program processing daemon.
Jun  4 00:48:46 moodle-vm cron[164323]: (CRON) INFO (pidfile fd = 3)
Jun  4 00:48:46 moodle-vm cron[164323]: (CRON) INFO (Running @reboot jobs)
Jun  4 00:50:51 moodle-vm crontab[164451]: (root) BEGIN EDIT (www-data)
Jun  4 00:51:55 moodle-vm crontab[164451]: (root) REPLACE (www-data)
Jun  4 00:51:55 moodle-vm crontab[164451]: (root) END EDIT (www-data)
Jun  4 00:52:01 moodle-vm CRON[164462]: (www-data) CMD (/usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/dev/null 2>&1)
utuhglobal@moodle-vm:~$ which php
/usr/bin/php
utuhglobal@moodle-vm:~$ ls /var/www/html
index-asli.html  moodle
utuhglobal@moodle-vm:~$ sudo crontab -u www-data -e