How to Install Moodle on Ubuntu 18.04
Moodle is a web-based open source software for e-learning or creating online learning classes. Moodle is widely applied in schools and colleges including in Indonesia.
The Moodle project is led by Moodle HQ which is financially supported by more than 80 Moodle partner companies.
Moodle features include:
- Modern, easy to use interface
- Personalised Dashboard
- Collaborative tools and activities
- All-in-one calendar
- Convenient file management
- Simple and intuitive text editor
For a complete list of Moodle features, read here.
0.Software used
The software used in this tutorial is:
- OS: Ubuntu 18.04
- Web server: Apache 2.4
- PHP Engine: PHP v7.2
- Database: MariaDB 10.1
- Moodle: Moodle v3.8
- Subomain: moodle.defnex.com
- SSL: Let’s Encrypt
1.Install Apache
Update Ubuntu first
1 2 | apt update apt upgrade -y |
Install Apache web server
1 2 | apt install apache2 -y systemctl status apache2 |
2.Install PHP
Install PHP
1 | apt install php php-common php-pspell php-curl php-gd php-intl php-mysql php-xml php-xmlrpc php-ldap php-zip php-soap php-mbstring libapache2-mod-php -y |
3.Install MariaDB
Install MariaDB database
1 2 3 | apt install mariadb-server -y systemctl status mariadb mysql_secure_installation |
Answer the question
1 2 3 4 5 | 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 |
Configure MariaDB
1 | vim /etc/mysql/mariadb.conf.d/50-server.cnf |
Add the configuration under [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 |
Create a database for Moodle
1 2 3 4 5 6 7 | mysql -u root -p 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 |
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 |
Create a folder for 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 |
Configure the virtual host for moodle.defnex.com
1 2 | cd /etc/apache2/sites-available/ vim moodle.defnex.com.conf |
Enter the virtual host configuration
1 2 3 4 5 6 7 8 9 10 11 | <VirtualHost *:80> ServerName moodle.defnex.com DocumentRoot /var/www/moodle/web <Directory /var/www/moodle/web> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ErrorLog /var/log/apache2/moodle.defnex.com_error.log CustomLog /var/log/apache2/moodle.defnex.com_requests.log combined </VirtualHost> |
Activate virtual host and restart Apache
1 2 3 | a2ensite moodle.defnex.com.conf systemctl restart apache2 systemctl status apache2 |
5.Install SSL Let’s Encrypt
Download certbot-auto
1 2 3 4 | cd curl -O https://dl.eff.org/certbot-auto mv certbot-auto /usr/local/bin/certbot-auto chmod 0755 /usr/local/bin/certbot-auto |
SSL request for the moodle.defnex.com subdomain
1 | certbot-auto --apache -d moodle.defnex.com |
Install packages, Do you want to continue? [Y/n], answer y
1 2 3 | Need to get 66.4 MB of archives. After this operation, 194 MB of additional disk space will be used. Do you want to continue? [Y/n] y |
Enter email address
1 | Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): hai@musaamin.web.id |
Agree Terms of Service
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 |
Consent to be sent information about Let’s Encrypt, you can answer Y or 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 |
An SSL certificate was created, changed and added a virtual host configuration for SSL.
1 2 3 | Obtaining a new certificate Performing the following challenges: http-01 challenge for moodle.defnex.com |
Then enter 2 to redirect HTTP to 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 |
The SSL install for moodle.defnex.com is complete
1 | Congratulations! You have successfully enabled https://moodle.defnex.com |
The SSL certificate is only valid for 90 days, run the renew command to renew the SSL certificate
1 | cerbot-auto renew |
6.Install Moodle
Browse http://moodle.defnex.com
Choose a language, Next
Fill Data directory with /var/www/moodle/data
Database driver, for Type choose MariaDB (native/mariadb)
Enter the database name, database user, and database password
Confirm the license, Continue
Check the server if the server is ready to install Moodle
Installation is running
Create an administrator account
Enter Full site name, Short name for site and Front page summary
If successful, go directly to the administrator dashboard
If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!
Donate via PayPal: https://paypal.me/musaamin
Works like a charm, thank you so much. Most moodle tutorials don’t include the domain setup tasks, even the official one for Ubuntu 18.04 doesn’t work that well. Thank you.
Bismillah. Pak musa, saya config vhost nya dengan nama domain yang saya beli sendiri, bisa di akses tp pas sy cek di url nya kok jadi naked IP ya? jadi misal domain sy moodle.co.id, tp saya lihat di address bar itu kok bukan moodle.co.id melainkan naked IP VPS sy ya pak? ada saran pak? terima kasih.
coba cek kembali konfigurasi virtual host