Fedora 28: Install Moodle for e-Learning platform

Table of Contents

1 Install Moodle

  • This article uses default SSL/TLS certicication file for https. Please change your SSL/TLS certification file.
  • If you use http instead of https, change 443 to 80 and delete SSLXXX directive in /etc/httpd/conf.d/moodle.conf.
  • Set your environment FQDN to MOODLE_FQDN.
  • MOODLE_PASSWD is password of moodle user in MySQL.

#!/bin/sh -e[ -z “${MOODLE_FQDN}” ] && MOODLE_FQDN=$(hostname)[ -z “${MOODLE_PASSWD}” ] && MOODLE_PASSWD=moodle_passwdmysql_install(){ sudo dnf install -y mariadb-server sudo systemctl enable mariadb sudo systemctl start mariadb cat<<EOF | sudo mysql -urootCREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;GRANT ALL PRIVILEGES ON moodle.* TO moodle@localhost IDENTIFIED BY ‘${MOODLE_PASSWD}’;exitEOF}moodle_install(){ # The moodle needs the following php extensions. sudo dnf install -y php php-mysqlnd php-gd php-intl php-mbstring php-zip php-soap php-xml php-xmlrpc php-json sudo dnf install -y git sudo mkdir -p /var/lib/moodle cd /usr/share sudo git clone https://github.com/moodle/moodle cd moodle sudo git checkout v3.4.2 -b v3.4.2 cat <<EOF | sudo tee config.php<?phpunset($CFG);global $CFG;$CFG = new stdClass();$CFG->dbtype = ‘mariadb’;$CFG->dbhost = ‘localhost’;$CFG->dbname = ‘moodle’;$CFG->dbuser = ‘moodle’;$CFG->dbpass = ‘${MOODLE_PASSWD}’;$CFG->prefix = ‘mdl_’;$CFG->wwwroot = ‘https://${MOODLE_FQDN}/moodle’;$CFG->dirroot = ‘/usr/share/moodle’;$CFG->dataroot = ‘/var/lib/moodle’;$CFG->directorypermissions = 0750;$CFG->admin = ‘admin’;$CFG->pathtodu = ‘$(which du)’;$CFG->unzip = ‘$(which unzip)’;$CFG->zip = ‘$(which zip)’;$CFG->respectsessionsettings = true;$CFG->disableupdatenotifications = true;$CFG->enablehtmlpurifier = true;if (file_exists(“$CFG->dirroot/lib/setup.php”)) { include_once(“$CFG->dirroot/lib/setup.php”);} else { if ($CFG->dirroot == dirname(__FILE__)) { echo “<p>Could not find this file: $CFG->dirroot/lib/setup.php</p>”; echo “<p>Are you sure all your files have been uploaded?</p>”; } else { echo “<p>Error detected in config.php</p>”; echo “<p>Error in: \$CFG->dirroot = ‘$CFG->dirroot’;</p>”; echo “<p>Try this: \$CFG->dirroot = ‘”.dirname(__FILE__).”‘;</p>”; } die;}EOF}apache_install(){ sudo dnf install -y httpd mod_ssl sudo chown -R apache:root /var/lib/moodle cat <<EOF | sudo tee /etc/httpd/conf.d/moodle.conf<VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key Alias /moodle /usr/share/moodle <Directory /usr/share/moodle> Options FollowSymLinks MultiViews AllowOverride None Require all granted </Directory></VirtualHost>EOF sudo firewall-cmd –add-service=https –permanent sudo firewall-cmd –reload sudo systemctl enable httpd sudo systemctl restart httpd}moodle_main(){ mysql_install moodle_install apache_install}moodle_main

2 Access to Moodle

Access to the following URL and setup Moodle. Accept this page’s certification to browser.



Android | Linux | SDL - Narrow Escape