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

[INPUT]

1 2 3 apt update apt upgrade -y apt install nginx -y

*2.Install MariaDB*

Install MariaDB database

[INPUT]

1 apt install mariadb-server -y

Mengamankan instalasi MariaDB

[INPUT]

1 mysql_secure_installation

Jawab pertanyaannya

[INPUT]

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

[INPUT]

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

Tambahkan konfigurasi di bawah *[mysqld]*

[INPUT]

1 2 3 4 default_storage_engine = innodb innodb_file_per_table = 1 innodb_file_format = Barracuda innodb_large_prefix = 1

MariaDB configuration

Restart MariaDB

[INPUT]

1 2 systemctl restart mariadb systemctl status mariadb

Login ke MariaDB

[INPUT]

1 mysql -u root -p

Membuat database untuk Moodle

[INPUT]

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

Create database

*3.Install PHP-FPM*

Install PHP-FPM beserta modulenya

[INPUT]

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*

[INPUT]

1 nano /etc/php/7.2/fpm/php.ini

Ubah opsi konfigurasi di bawah ini

[INPUT]

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 = date.timezone = Asia/Jakarta

Restart PHP-FPM

[INPUT]

1 2 systemctl restart php7.2-fpm systemctl status php7.2-fpm

*4.Download Moodle*

Download Moodle v3.8

[INPUT]

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

[INPUT]

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*

[INPUT]

1 2 cd /etc/nginx/conf.d nano moodle.defnex.com.conf

Masukkan konfigurasi di bawah ini

[INPUT]

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

[INPUT]

1 2 3 nginx -t systemctl restart nginx systemctl status nginx

*5.Install SSL Let”€™s Encrypt*

Pasang repository certbot

[INPUT]

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

[INPUT]

1 apt install certbot python3-certbot-nginx -y

Request SSL untuk subdomain *moodle.defnex.com*

[INPUT]

1 certbot –nginx -d moodle.defnex.com

Masukkan alamat email

[INPUT]

1 Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to cancel): hai@musaamin.web.id          

Setujui ToS

[INPUT]

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.

[INPUT]

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.

[INPUT]

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.

[INPUT]

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

[INPUT]

1 Congratulations! You have successfully enabled https://moodle.defnex.com    

Sertifikat SSL hanya berlaku selama 90 hari, renew untuk memperbarui sertifikat SSL

[INPUT]

1 cerbot renew  

*6.Install Moodle*

Browse *https://moodle.defnex.com*

Pemilihan bahasa, *Next*

Choose a language

Data directory isi dengan */var/www/moodle/data*

Confirm paths

Database driver, Type pilih *MariaDB (native/mariadb)*

Choose database driver

Masukkan nama database, user database, dan password database

Database settings

Konfirmasi lisensi, *Continue*

Confirm license

Pemeriksaan server apakah server sudah siap untuk install Moodle

Server checks

Installation berjalan

Installation

Membuat akun administrator

Administrator account

Masukkan *Full site name*, *Short name for site* dan *Front page summary*

Front page settings

Jika berhasil, langsung masuk ke dashboard administrator

Moodle dashboard

Selamat mencoba 🙂

Leave a Reply

Your email address will not be published.