Cara Install Moodle dengan Nginx di Ubuntu 18.04
Saya sudah pernah membahas tentang cara install Moodle di Ubuntu 18.04 di mana web server yang digunakan adalah Apache web server. Kali ini Moodle diinstall di atas Nginx web server.
0.Perangkat Lunak yang digunakan
Perangkat lunak yang digunakan di tutorial ini adalah:
- OS: Ubuntu 18.04
- Web server: Nginx 1.14
- PHP Engine: PHP v7.2
- Database: MariaDB 10.1
- Moodle: Moodle v3.8
- Subomain: moodle.defnex.com
- SSL: Let’s Encrypt
1.Install Nginx
Update Ubuntu lalu install Nginx
1 2 3 | apt update apt upgrade -y apt install nginx -y |
2.Install MariaDB
Install MariaDB database
1 | apt install mariadb-server -y |
Mengamankan instalasi MariaDB
1 | mysql_secure_installation |
Jawab pertanyaannya
1 2 3 4 5 6 | Enter current password for root (enter for none): ENTER Set 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 /etc/mysql/mariadb.conf.d/50-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 MariaDB
1 2 | systemctl restart mariadb systemctl status mariadb |
Login ke MariaDB
1 | mysql -u root -p |
Membuat database untuk Moodle
1 2 3 4 5 | CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'usrmoodle'@'localhost' IDENTIFIED BY 'secret'; GRANT ALL PRIVILEGES ON moodle.* TO 'usrmoodle'@'localhost'; FLUSH PRIVILEGES; exit |
3.Install PHP-FPM
Install PHP-FPM beserta modulenya
1 | apt install php-fpm php-common php-pspell php-curl php-gd php-intl php-mysql php-xml php-xmlrpc php-ldap php-zip php-soap php-mbstring -y |
Konfigurasi php.ini
1 | nano /etc/php/7.2/fpm/php.ini |
Ubah opsi konfigurasi di bawah ini
1 2 3 4 5 6 7 | memory_limit = 256M upload_max_filesize = 64M post_max_size = 64M max_execution_time = 360 max_input_time = 360 cgi.fix_pathinfo = 0 date.timezone = Asia/Jakarta |
Restart PHP-FPM
1 2 | systemctl restart php7.2-fpm systemctl status php7.2-fpm |
4.Download Moodle
Download Moodle v3.8
1 2 | wget https://download.moodle.org/download.php/direct/stable38/moodle-latest-38.tgz tar xzvf moodle-latest-38.tgz |
Membuat folder untuk Moodle
1 2 3 4 | mkdir -p /var/www/moodle/data mv moodle /var/www/moodle/web chown -R www-data:www-data /var/www/moodle chmod -R 755 /var/www/moodle |
Konfigurasi Nginx server block untuk moodle.defnex.com
1 2 | cd /etc/nginx/conf.d nano moodle.defnex.com.conf |
Masukkan konfigurasi di bawah ini
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | server { listen 80; server_name moodle.defnex.com; root /var/www/moodle/web; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location /dataroot/ { internal; alias /var/www/moodle/data; } location ~ [^/]\.php(/|$) { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } |
Tes dan restart Nginx
1 2 3 | nginx -t systemctl restart nginx systemctl status nginx |
5.Install SSL Let’s Encrypt
Pasang repository certbot
1 2 3 4 | apt install software-properties-common -y add-apt-repository universe add-apt-repository ppa:certbot/certbot apt update |
Install certbot untuk Nginx
1 | apt install certbot python3-certbot-nginx -y |
Request SSL untuk subdomain moodle.defnex.com
1 | certbot --nginx -d moodle.defnex.com |
Masukkan alamat email
1 | Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): hai@musaamin.web.id |
Setujui ToS
1 2 3 | Please read the Terms of Service at https://letsencrypt.org/documents/ LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A |
Persetujuan untuk dikirimi informasi mengenai Let’s Encrypt, bisa jawab Y atau N.
1 2 3 | Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N |
Sertifikat SSL dibuat, mengubah dan menambahkan konfigurasi virtual host untuk SSL.
1 2 3 | Obtaining a new certificate Performing the following challenges: http-01 challenge for moodle.defnex.com |
Kemudian pilih 2 untuk redirect HTTP ke HTTPS.
1 2 3 4 5 6 | Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 |
Install SSL untuk moodle.defnex.com selesai
1 | Congratulations! You have successfully enabled https://moodle.defnex.com |
Sertifikat SSL hanya berlaku selama 90 hari, renew untuk memperbarui sertifikat SSL
1 | cerbot renew |
6.Install Moodle
Browse https://moodle.defnex.com
Pemilihan bahasa, Next
Data directory isi dengan /var/www/moodle/data
Database driver, Type pilih MariaDB (native/mariadb)
Masukkan nama database, user database, dan password database
Konfirmasi lisensi, Continue
Pemeriksaan server apakah server sudah siap untuk install Moodle
Installation berjalan
Membuat akun administrator
Masukkan Full site name, Short name for site dan Front page summary
Jika berhasil, langsung masuk ke dashboard administrator
Selamat mencoba 🙂
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for moodle.defnex.com
Waiting for verification…
Challenge failed for domain moodle.defnex.com
http-01 challenge for moodle.defnex.com
Cleaning up challenges
Some challenges have failed.
help me,……. i’m failed in this step
moodle.defnex.com adalah subdomain contoh yang digunakan di tutorial ini. gunakan domain milik sendiri.
diposisi direktori manakah kita saat mengextract moodle ?
di posisi yang sama saat menjalankan download
Bg musa..saya udah install moodle..tapi kenapa mengupload video diatas 5 Mb selalu ‘error connecting to server’..padahal size limit di php.ini sudah saya ubah..pilihan file and upload juga sudah diubah ke 500 Mb tapi tetap tidak bisa juga..mohon bantuannya bg
cek permission foldernya
Saya sudah mencoba beberapa kali menginstal moodle di server Linux Ubuntu maupun Debian dengan web server NGINX, tetapi kenapa ya pak selalu berhenti di proses instalasi membuat Admin Moodle. Tampilan di Admin Moodle menjadi berantakan dan formulir password tidak bisa di tampilakn / tidak bisa di isi password, padahal pada saat instalasi berjalan dengan lancar. Mohon pencerahannya pak Musa. Terima kasih.
saya gak tau ini, belum pernah mengalami. coba cek error log Nginx, atau tes install pakai Apache, kalau sudah selesai baru ganti dengan Nginx
mas, mau tanya kebutuhan server untuk moodle dengan user akses 500+ saat ujian berapa ya ? apakah ada saran lebih efisien menggunakan apache/nginx ?
coba mulai dari RAM 8GB 4CPU. coba pelajari rekomendasi performa dari moodle
saya juga mengalami kendala seperti di atas,saya cek di log error nya begini bang:
2021/12/15 15:58:19 [error] 1285#1285: *1749 FastCGI sent in stderr: “PHP message: Cannot find session record oip3cf4c4sorl3560rinp7l7v9 for user 2, creating new session” while reading response header from upstream, client: 192.168.7.8, server: edu1.pdk, request: “GET /theme/styles.php/boost/1639457180_1/all HTTP/1.1”, upstream: “fastcgi://unix:/run/php74-fpm.sock:”, host: “192.168.7.6”, referrer: “http://192.168.7.6/user/editadvanced.php?id=2”
2021/12/15 15:58:19 [error] 1286#1286: *1751 FastCGI sent in stderr: “PHP message: Cannot find session record oip3cf4c4sorl3560rinp7l7v9 for user 2, creating new session” while reading response header from upstream, client: 192.168.7.8, server: edu1.pdk, request: “GET /lib/javascript.php/1639457180/lib/babel-polyfill/polyfill.min.js HTTP/1.1”, upstream: “fastcgi://unix:/run/php74-fpm.sock:”, host: “192.168.7.6”, referrer: “http://192.168.7.6/user/editadvanced.php?id=2”
2021/12/15 15:58:19 [error] 1288#1288: *1757 FastCGI sent in stderr: “PHP message: Cannot find session record oip3cf4c4sorl3560rinp7l7v9 for user 2, creating new session” while reading response header from upstream, client: 192.168.7.8, server: edu1.pdk, request: “GET /lib/javascript.php/1639457180/lib/requirejs/require.min.js HTTP/1.1”, upstream: “fastcgi://unix:/run/php74-fpm.sock:”, host: “192.168.7.6”, referrer: “http://192.168.7.6/user/editadvanced.php?id=2”
2021/12/15 15:59:12 [error] 1286#1286: *1811 FastCGI sent in stderr: “PHP message: Cannot find session record 8bb834d2t96dtgud75shvhtcma for user 2, creating new session” while reading response header from upstream, client: 192.168.7.8, server: edu1.pdk, request: “GET /theme/styles.php/boost/1639457180_1/all HTTP/1.1”, upstream: “fastcgi://unix:/run/php74-fpm.sock:”, host: “192.168.7.6”, referrer: “http://192.168.7.6/user/editadvanced.php?id=2”