Bitnami Moodle for Oracle Cloud Infrastructure Classic

Description

Moodle is an open source online Learning Management System (LMS) widely used at universities, schools, and corporations worldwide. It is modular and highly adaptable to any type of online learning.

First steps with the Bitnami Moodle Stack

Welcome to your new Bitnami application running on Oracle Cloud Infrastructure Classic! Here are a few questions (and answers!) you might need when first starting with your application.

What credentials do I need?

You need two sets of credentials:

The application credentials, consisting of a username and password. These credentials allow you to log in to your new Bitnami application.

The server credentials, consisting of an SSH username and key. These credentials allow you to log in to your Oracle Cloud Infrastructure Classic server using an SSH client and execute commands on the server using the command line.

What is the administrator username set for me to log in to the application for the first time?

Username: user

What is the administrator password?

If you used the Oracle Cloud Infrastructure Classic Console or the Oracle Cloud Infrastructure Classic Marketplace, click here for instructions.

What are the default ports?

A port is an endpoint of communication in an operating system that identifies a specific process or a type of service. Bitnami stacks include several services or servers that require a port.

For security reasons, Oracle Cloud Infrastructure Classic have some or all their ports closed. For those applications launched from the Oracle Cloud Infrastructure Classic marketplace, make sure that the default access ports are opened. Check the how to open the server ports for remote access section to learn how to open ports in order to allow remote access to your server.

Port 22 is the default port for SSH connections.

Bitnami opens some ports for the main servers. These are the ports opened by default: 80, 443.

How to start or stop the services?

Each Bitnami stack includes a control script that lets you easily stop, start and restart services. The script is located at /opt/bitnami/ctlscript.sh. Call it without any service name arguments to start all services:

$ sudo /opt/bitnami/ctlscript.sh start

Or use it to restart a single service, such as Apache only, by passing the service name as argument:

$ sudo /opt/bitnami/ctlscript.sh restart apache

Use this script to stop all services:

$ sudo /opt/bitnami/ctlscript.sh stop

Restart the services by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh restart

Obtain a list of available services and operations by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh

How to configure outbound email settings?

This is required so your application can send notifications via email. Find below an example of configuring the email using a Gmail account from the Moodle Administration Panel.

To configure the application to use other third-party SMTP services for outgoing email, such as SendGrid or Mandrill, refer to the FAQ.

Troubleshooting Gmail SMTP issues

If you are using Gmail as the outbound email server and you are not able to send email correctly, Google may be blocking sign-in attempts from your apps or devices. Depending on whether or not you use Google Apps, the steps to correct this will differ.

For Google Apps users

If you are a Google Apps user, you will need your administrator to allow users to change the policy for less secure apps. If you are a Google Apps administrator, follow these steps:

Look for the section "Less secure apps" and then click on "Go to settings for less secure apps".

Select "Allow users to manage their access to less secure apps".

For other Google users

If you do not use Google Apps, follow the steps in the following sections, depending on whether 2-step verification has been enabled on the account or not.

If 2-step verification has not been enabled on the account, follow these steps:

Browse to the "Less secure apps" page and log in using the account you are having problems with. This option is typically required by many popular email clients, such as Outlook and Thunderbird, and should not be considered unsafe.

Select the "Turn on" option.

If 2-step verification has been enabled on the account, you have to generate an app password. Follow these steps:

How to install a plugin on Moodle?

Using the Web interface

Since Moodle 2.5 you can install any plugin from the Moodle administration panel.

Using a manual upload

With this method, you need to copy and uncompress the plugin to the server file system in the correct directory. You can check that the module has been correctly installed in the "Settings -> Site administration -> Notifications" menu (as the Moodle admin user). You can disable the web installer and use an SFTP client or scp to manually copy the files.

How to create a full backup of Moodle?

Backup

The Bitnami Moodle Stack is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

Follow these steps:

Change to the directory in which you wish to save your backup:

$ cd /your/directory

Stop all servers:

$ sudo /opt/bitnami/ctlscript.sh stop

Create a compressed file with the stack contents:

$ sudo tar -pczvf application-backup.tar.gz /opt/bitnami

Restart all servers:

$ sudo /opt/bitnami/ctlscript.sh start

You should now download or transfer the application-backup.tar.gz file to a safe location.

Restore

Follow these steps:

Change to the directory containing your backup:

$ cd /your/directory

Stop all servers:

$ sudo /opt/bitnami/ctlscript.sh stop

Move the current stack to a different location:

$ sudo mv /opt/bitnami /tmp/bitnami-backup

Uncompress the backup file to the original directoryv

$ sudo tar -pxzvf application-backup.tar.gz -C /

Start all servers:

$ sudo /opt/bitnami/ctlscript.sh start

If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

How to upgrade Moodle?

It is strongly recommended that you create a backup before starting the update process. If you have important data, it is advisable that you create and try to restore a backup to ensure that everything works properly.

NOTE: Replace the MY_THEME and MY_MOD placeholders with the directory or path names for your downloaded and installed themes and modules (these are different from the ones shipped by Bitnami).

Navigate to the application from a browser and follow the steps to upgrade the database to the latest version.

NOTE: If you want to install modules or plugins from the Moodle administration panel, refer to the migration steps.

How to enable HTTPS support with SSL certificates?

NOTE: The steps below assume that you are using a custom domain name and that you have already configured the custom domain name to point to your cloud server.

Bitnami images come with SSL support already pre-configured and with a dummy certificate in place. Although this dummy certificate is fine for testing and development purposes, you will usually want to use a valid SSL certificate for production use. You can either generate this on your own (explained here) or you can purchase one from a commercial certificate authority.

Once you obtain the certificate and certificate key files, you will need to update your server to use them. Follow these steps to activate SSL support:

Use the table below to identify the correct locations for your certificate and configuration files.

NOTE: If you use different names for your certificate and key files, you should reconfigure the SSLCertificateFile and SSLCertificateKeyFile directives in the corresponding Apache configuration file to reflect the correct file names.

If your certificate authority has also provided you with a PEM-encoded Certificate Authority (CA) bundle, you must copy it to the correct location in the previous table. Then, modify the Apache configuration file to include the following line below the SSLCertificateKeyFile directive. Choose the correct directive based on your scenario and Apache version:

Variable

Value

Apache configuration file

/opt/bitnami/apache2/conf/bitnami/bitnami.conf

Directive to include (Apache v2.4.8+)

SSLCACertificateFile "/opt/bitnami/apache2/conf/server-ca.crt"

Directive to include (Apache < v2.4.8)

SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"

NOTE: If you use a different name for your CA certificate bundle, you should reconfigure the SSLCertificateChainFile or SSLCACertificateFile directives in the corresponding Apache configuration file to reflect the correct file name.

Once you have copied all the server certificate files, you may make them readable by the root user only with the following commands:

How to create an SSL certificate?

OpenSSL is required to create an SSL certificate. A certificate request can then be sent to a certificate authority (CA) to get it signed into a certificate, or if you have your own certificate authority, you may sign it yourself, or you can use a self-signed certificate (because you just want a test certificate or because you are setting up your own CA).

Note that if you use this encrypted key in the Apache configuration file, it will be necessary to enter the password manually every time Apache starts. Regenerate the key without password protection from this file as follows:

How to debug Apache errors?

Once Apache starts, it will create two log files at /opt/bitnami/apache2/logs/access_log and /opt/bitnami/apache2/logs/error_log respectively.

The access_log file is used to track client requests. When a client requests a document from the server, Apache records several parameters associated with the request in this file, such as: the IP address of the client, the document requested, the HTTP status code, and the current time.

The error_log file is used to record important events. This file includes error messages, startup messages, and any other significant events in the life cycle of the server. This is the first place to look when you run into a problem when using Apache.

If no error is found, you will see a message similar to:

Syntax OK

Updating the IP address or hostname

Moodle requires updating the IP address/domain name if the machine IP address/domain name changes. The bnconfig tool also has an option which updates the IP address, called --machine_hostname (use --help to check if that option is available for your application). Note that this tool changes the URL to http://NEW_DOMAIN/moodle.

NOTE: Be sure that your domain is propagated. Otherwise, this will not work. You can verify the new DNS record by using the Global DNS Propagation Checker and entering your domain name into the search field.

You can also change your hostname by modifying it in your hosts file. Enter the new hostname using your preferred editor.

$ sudo nano /etc/hosts

Add a new line with the IP address and the new hostname. Here's an example. Remember to replace the IP-ADDRESS and DOMAIN placeholders with the correct IP address and domain name.

How to access phpMyAdmin?

For security reasons, phpMyAdmin is accessible only when using 127.0.0.1 as the hostname. To access it from a remote system, you must create an SSH tunnel that routes requests to the Web server from 127.0.0.1. This implies that you must be able to connect to your server over SSH in order to access these applications remotely.

IMPORTANT: Before following the steps below, ensure that your Web and database servers are running.

NOTE: The steps below suggest using port 8888 for the SSH tunnel. If this port is already in use by another application on your local machine, replace it with any other port number greater than 1024 and modify the steps below accordingly. Similarly, if you have enabled Varnish, your stack's Web server might be running on port 81. In this case, modify the steps below to use port 81 instead of port 80 for the tunnel endpoint.

Accessing phpMyAdmin on Windows

Watch the following video to learn how to easily access phpMyAdmin on Windows through an SSH tunnel:

Once you have your SSH client correctly configured and you tested that you can successfully access to your instance via SSH, you need to create an SSH tunnel in order to access phpMyAdmin. For doing so, follow these steps:

In the "Connection -> SSH -> Tunnels" section, add a new forwarded port by introducing the following values:

Source port: 8888

Destination: localhost:80

This will create a secure tunnel by forwarding a port (the "destination port") on the remote server to a port (the "source port") on the local host (127.0.0.1 or localhost).

Click the "Add" button to add the secure tunnel configuration to the session. (You'll see the added port in the list of "Forwarded ports").

In the "Session" section, save your changes by clicking the "Save" button.

Click the "Open" button to open an SSH session to the server. The SSH session will now include a secure SSH tunnel between the two specified ports.

Access the phpMyAdmin console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin.

How to upload files to the server with SFTP?

Although you can use any SFTP/SCP client to transfer files to your server, the link below explains how to configure FileZilla (Windows, Linux and Mac OS X), WinSCP (Windows) and Cyberduck (Mac OS X). It is required to use your server's private SSH key to configure the SFTP client properly. Choose your preferred application and follow the steps in the link below to connect to the server through SFTP.

Click the "Continue" button. You'll be prompted to configure the activity module.

Enter the URL and salt (security key) to your BigBlueButton server (or use the default values for testing).

Click the "Save Changes" button.

At this point, enter any course, turn editing on, and add a BigBlueButtonBN activity link to the class.

How to disable the admin web interface option for installing add-ons?

To hide this option from the admin web interface, edit the configuration file at /opt/bitnami/apps/moodle/htdocs/config.php and set:

$CFG->disableonclickaddoninstall = true;

On Linux systems, also remove the write permissions from the web server group in the Moodle directories:

$ find /opt/bitnami/apps/moodle/htdocs/ -type d 755

How to install a cron task for Moodle?

Moodle requires a cron task that must be run regularly. The administrator can do this from the Admin panel's "Site Administration -> Notifications" menu. To run this task in the background, create a cron job.

How to migrate your Moodle installation?

There are two important steps when migrating a Moodle Stack: migrate the database and migrate the moodledata/ folder. You may want to migrate the themes/ and modules/ folders if you have them installed also. To make this process easier, divide them into four sub-steps.

Export the database

Copy the Moodle data folder

In this step, you just need to copy the /opt/bitnami/apps/moodle/moodledata directory to the machine where you have installed the new Moodle. When doing this step, copy the exported database file too. If you have themes or modules installed and you want to keep them, you must also copy them.

Import the database

Delete the tables in the bitnami_moodle database. To do so, the easiest way would be to use phpMyAdmin, choose the bitnami_moodle database, select all the tables and drop them.

Another option would be to do it manually. Remember to replace the PASSWORD placeholder with the password in the /opt/bitnami/apps/moodle/htdocs/config.php file.

After that, import the database. You can do it manually or using phpMyAdmin.

Substitute moodledata/ (and other) directories

Finally, you just need to substitute the moodledata/ directory, as well as the themes/ and modules/ directories if needed.

Once these steps are complete, restart the Apache server and access Moodle through the browser. If you log in as an administrator, you will be asked to update your database. Click to do this and the migration of your Moodle stack will be completed.

Thanks to @aguayomanel and @pivot_1990_69 for their guides.

How to secure your installation?

One of our main goals is to configure Bitnami applications in the most secure way. However, sometimes, it is necessary to find a compromise between security and ease of use.

This is the case with Moodle since version 2.5. In Moodle 2.5, a new feature for installing add-ons from the admin web interface has been implemented. However, to allow this feature on Unix, it is required to grant write permissions to the web server group. You can make your configuration more secure by disabling this feature and installing Moodle plugins by copying the files to the right directory. However, this will require uploading the files to your server using other tools like SFTP clients or scp.