Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andisugandi/dc922235cbf51cba1422b25afec1558d to your computer and use it in GitHub Desktop.
Save andisugandi/dc922235cbf51cba1422b25afec1558d to your computer and use it in GitHub Desktop.

Moodle

MOODLE (singkatan dari Modular Object-Oriented Dynamic Learning Environment) adalah paket perangkat lunak yang diproduksi untuk kegiatan belajar berbasis internet dan situs web yang menggunakan prinsip social constructionist pedagogy.

Hardware Requirement

  • Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum.
  • Processor: 1GHz (min), 2GHz dual core or more recommended.
  • Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server
  • Consider separate servers for the web "front ends" and the database. It is much easier to "tune"

Persiapan

  • VPS CentOS 7
  • root akses

Apa yang akan kita lakukan

  • Install Nginx
  • Install and Configure PHP-FPM
  • Install and Configure MariaDB
  • Download and Configure Moodle
  • Configure SSL and Virtual Host
  • Configure SELinux and Firewalld
  • Installing Moodle
  • Testing

Install Nginx

yum -y install epel-release
yum -y install nginx

systemctl start nginx
systemctl enable nginx

ss -plntu

Install and Configure PHP-FPM

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install -y graphviz aspell php70w-fpm php70w-cli php70w-pspell php70w-curl php70w-gd php70w-intl php70w-mysql php70w-xml php70w-xmlrpc php70w-ldap php70w-zip php70w-json php70w-opcache php70w-readline php70w-mbstring php70w-soap

vim /etc/php.ini

uncomment :
cgi.fix_pathinfo=0

cd /etc/php-fpm.d/
vim www.conf

define:
user = situs
group = situs
listen = /run/php-fpm/php-fpm.sock
listen.owner = situs
listen.group = situs
listen.mode = 0660
security.limit_extensions = .php
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

mkdir -p /var/lib/php/session/
chown -R nginx:nginx /var/lib/php/session/

chown -R nginx:nginx /run/php-fpm/

adduser situs

systemctl start php-fpm
systemctl enable php-fpm

ss -lx | grep php-fpm.sock

Install and Configure MariaDB

yum -y install mariadb-server mariadb

vim /etc/my.cnf

define :
default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

systemctl start mariadb
systemctl enable mariadb

mysql_secure_installation

Set root password? [Y/n] Y
New password:
Re-enter new password:

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

mysql -u root -p


CREATE DATABASE moodledb;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'passwordyangsangataman';
GRANT ALL PRIVILEGES ON moodledb.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'passwordyangsangataman';
FLUSH PRIVILEGES;

Download and Configure Moodle

yum install -y wget

su - situs

ambil rilis terakhir dari https://github.com/moodle/moodle/releases

wget -O moodle.tar.gz https://github.com/moodle/moodle/archive/v3.5.2.tar.gz
tar -xvzf moodle.tar.gz
mv moodle-3.5.2 public
mkdir moodledata
cd public/
ls

Configure SSL and Virtual Host


cd /etc/nginx/
vim conf.d/moodle.conf

------------------- nginx http
upstream php-handler {
    server unix:/run/php-fpm/php-fpm.sock;
}
server {
        server_name          moodle.samsul.web.id;
 
        listen               80;
        
        # Root Moodle Data DIrectory
        root /home/situs/public;
        rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;
 
        location ^~ / {
                try_files $uri $uri/ /index.php?q=$request_uri;
                index index.php index.html index.htm;
 
                location ~ \.php$ {
                        include fastcgi.conf;
                        fastcgi_pass php-handler;
                }
        }
}
-------------------- nginx http


## Self-sign SSL
mkdir -p /etc/nginx/ssl/
openssl req -new -x509 -days 365 -nodes -out /etc/nginx/ssl/moodle.crt -keyout /etc/nginx/ssl/moodle.key

chmod 600 /etc/nginx/ssl/moodle.key

-------------------- nginx https
# PHP Upstream Handler
upstream php-handler {
    server unix:/run/php-fpm/php-fpm.sock;
}
 
# Nginx redirect HTTP to HTTPS - moodle.samsul.web.id
server {
    listen 80;
    server_name moodle.samsul.web.id;
    # enforce https
    return 301 https://$server_name$request_uri;
}
 
# HTTPS Configuration
server {
        server_name          moodle.samsul.web.id;
 
        listen               *:443 ssl http2;
        listen               [::]:443 ssl http2;
 
        # SSL Configuration    
        ssl  on;
        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        ssl_session_tickets off;
        #ssl_stapling on;
        #ssl_stapling_verify on;
        resolver_timeout 5s;
        ssl_certificate /etc/nginx/ssl/moodle.crt;
        ssl_certificate_key /etc/nginx/ssl/moodle.key;
        
        # Root Moodle Data DIrectory
        root /home/situs/public;
        rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;
 
        location ^~ / {
                try_files $uri $uri/ /index.php?q=$request_uri;
                index index.php index.html index.htm;
 
                location ~ \.php$ {
                        include fastcgi.conf;
                        fastcgi_pass php-handler;
                }
        }
}
---------------------- nginx

nginx -t
systemctl restart nginx

Configure SELinux and Firewalld

vim /etc/selinux/config

SELINUX=disabled
#SELINUX=enabled

yum -y install firewalld

systemctl start firewalld
systemctl enable firewalld

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=ssh

firewall-cmd --reload
firewall-cmd --list-all


Installing Moodle

bukan browser http://ip-servermu-atau-hostname next-next-next

Referensi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment