This repository contains information about setting up an Ubuntu-VM for Moodle development without or with Opencast as well as helper scripts, to make this process straightforward. In the following guide, VirtualBox 6.1 is used as virtualization software.
Note - Under construction
This guide contains only the setup of the Ubuntu-VM so far. Other parts will follow as soon as possible.
Copyright (C) 2022 Matthias Kollenbroich.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
You should have received a copy of the GNU Free Documentation License along with this document. If not, see https://www.gnu.org/licenses/.
To create an Ubuntu-VM with VirtualBox, do the following steps:
- Download (from https://www.virtualbox.org) and install VirtualBox.
- Download an Ubuntu image (iso file from https://ubuntu.com/download/desktop).
- Start VirtualBox and create a new virtual machine:
- Name and operating system:
- Choose a name.
- Choose a machine folder: This is where your virtual machines will be stored, so you can resume working on them, whenever you like.
- Type: Linux
- Version: Ubuntu (64-bit)
- Memory size:
- Select the amount of RAM from your main PC, that the virtual machine will access. Be sure to remain inside the green bar, to ensure, you can continue to work outside the VM, whilst it is running.
- Hard disk:
- Select Create a virtual hard disk now.
- Hard disk file type:
- Select VDI (VirtualBox Disk Image).
- Storage on physical hard disk:
- Select Dynamically allocated.
- File location and size:
- Choose a path for the virtual hard disk file (default is okay).
- Choose a size for the virtual hard disk (should be at least 32 GB).
- Name and operating system:
- Install the Ubuntu image:
- Launch the newly created virtual machine.
- Select the downloaded Ubuntu image (iso file).
- Click Start.
- Select Try or Install Ubuntu from the boot menu.
- Install Ubuntu Desktop normally:
- Choose a language.
- Select Install Ubuntu.
- Choose a keyboard layout.
- Choose Normal installation and check Download updates while installing Ubuntu.
- Choose Erase disk and install Ubuntu and click Install Now.
- Click Continue.
- Select a location.
- Create your account (e.g., username is moodle-dev and password is admin as well as select Log in automatically).
- Click Restart Now after installation.
- Press Enter, when you see the text Please remove installation medium, then press ENTER.
- Select your desired settings in the windows, that are shown after the first login.
- If there are a software updates, install them and restart the VM, if required.
- Change the screen resolution to a fitting one:
- In the Ubuntu-VM, go to Settings -> Displays and change the resolution to a fitting one (the VirtualBox window for this Ubuntu-VM will have this size).
In addition, it is very helpful for a better performance of the complete VM, to increase the amount of processor cores under Settings -> System -> Processor in VirtualBox.
Furthermore, it is useful, to apply the following power settings (under Settings -> Power) in the VM,
since the VM is used as a server, for a better performance:
If the VM is displayed in, e.g., 4k, one should change the Scale Factor in the settings of the VM in VirtualBox under Display to, e.g., 200%, for a better performance, too.
For Moodle a web server is required. For this guide, this web server will be Apache. A Moodle installation must be installed to the document root directory of Apache (/var/www/html) and should not be writeable by the web server user. Furthermore, for development it is very helpful, to map this directory to a directory on the host system of the VM. To do so, do the following steps:
- Create the directory /var/www/html on the VM, if it does not exist already, with the command:
sudo mkdir -p /var/www/html
- Make the Moodle installations not writeable by the web server user by executing the following commands on the VM:
sudo chown -R root /var/www/html sudo chmod -R 0755 /var/www/html
- To create the mapping for the Moodle installations directory, a shared folder must be added to the VM.
To do so, do the following steps:
- Install some required packages for the installation of the Guest Additions on the VM with the command:
sudo apt-get install build-essential
- Select Devices -> Insert Guest Additions CD image... from the menu of the window of the VM on the host system.
- After the disk has been inserted, on the VM navigate to the directory /media/<USER>/VBox_GAs_<VERSION>,
whereat <USER> is the name of your account on the VM, and execute the following command:
sudo sh ./VBoxLinuxAdditions.run
- Restart the VM after checking, that there were no errors (note, that the resolution of the VM is automatically adjusted to the size of the window of the VM, if the Guest Additions have been installed).
- To access shared/mapped folders, a user must be added to the user group vboxsf. To do so,
run the following command on the VM and restart the VM afterwards, whereat <USER> is the name
of your account on the VM:
sudo adduser <USER> vboxsf
- Shutdown the VM.
- Navigate to Settings -> Shared Folders for the VM in VirtualBox.
- Add a new shared folder by right-clicking on the list of shared folders.
- Select the folder on the host system, that should be shared/mapped, set it not to read-only as well as to permanent, enable automatic mounting, leave the folder name as default (.) and enter the path /var/www/html as mount point (the selected folder from the host system will appear now as the folder /var/www/html on the VM automatically; note, that the shared folder on the host system will contain the Moodle versions for the VM in this guide).
- Accept the settings for the VM and start the VM again, to check, whether the mapping works.
- Install some required packages for the installation of the Guest Additions on the VM with the command:
Note, that a restart of the VM is required/recommended, when you change the shared folder settings, because of undefined behavior (some files are missing, if you access the shared folder to fast after changing the settings, or mounting of the folder fails etc.).
By default, a Moodle installation on the VM cannot be accessed from a browser on the host, because the VM is connected to a private network internal to VirtualBox and invisible to the host. Therefore, network services on the VM are not accessible by the host machine or by other computers on the same network. However, VirtualBox can make the VM available to the host.
To access the web server/a Moodle installation of the VM from the host, the Host-Only Networking feature
of VirtualBox can be used. One can describe the Host-Only Networking feature with
(see https://www.virtualbox.org/manual/ch06.html):
The virtual machines can talk to each other and the host as if they were connected through a physical Ethernet switch.
Furthermore, a physical networking interface need not be present, and the virtual machines cannot talk to
the world outside the host since they are not connected to a physical networking interface.
- At first, crate a Host-Only Network by doing the following steps:
- In VirtualBox, select File -> Host Network Manager... and click on Create.
- Click on Properties with this new entry selected.
- In the Adapter tab, select Configure Adapter Manually and use the following settings:
IPv4 Address: 192.168.56.1
IPv4 Network Mask: 255.255.255.0
IPv6 Address: leaf the field empty or as the default, if the field is not editable
IPv6 Prefix Length: 0 or as the default, if the field is not editable
In the DHCP Server tab, make sure, that the Enable Server box is checked, and use the following settings:
Server Address: 192.168.56.100
Server Mask: 255.255.255.0
Lower Address Bound: 192.168.56.101
Upper Address Bound: 192.168.56.101 (note, that the DHCP server serves only one IP address, namely, 192.168.56.101)
- Add a Host-Only Adapter to the VM by doing the following steps:
- Open the settings of the VM in VirtualBox and click on the Network tab.
- Under the Adapter 2 tab, enter the following settings and accept them afterwards:
Enable Network Adapter: Checked
Attached to: Host-only Adapter
Name: the name of the network, you created in the previous step, e.g., vboxnet0
- You should check, whether the Host-Only Network is available (the VM should be running), e.g., with
the following command, executed on the host:
ping 192.168.56.101
When you have done all the previous steps, you should have a working Ubuntu-VM (with a mapped/shared folder), that is accessible from the host via network. This VM will be a kind of basic VM, that is used for every installation of Moodle or Opencast in this guide. For it, a Full Clone of this VM will always be created. A Full Clone of a VM in VirtualBox is an exact copy of the original VM. To create a Full Clone of a VM with VirtualBox, do the following steps:
- Right-click on the VM in VirtualBox and select Clone ....
- Enter a name of your choice, keep the default path, select Include all network adapter MAC addresses for MAC Address Policy and check Keep Disk Names as well as Keep Hardware UUIDs for Additional Options.
- Click on Continue.
- Select Full Clone and click on Clone.
For the previously created basic VM or for a clone of it, you can install Moodle and Opencast as well as configure them
directly by running the script scripts/setup_moodle_system_with_opencast.sh as superuser on the VM.
Running this script includes the installation and configuration of the Opencast Moodle Plugins via their default branches
or via a chosen branch and Moodle will be installed at /var/www/html on the VM afterwards.
This script has the following parameters, to choose a PHP, Java, Moodle and Opencast version as well as
a branch for the Opencast Moodle Plugins:
php_version
:
The version of PHP, that is used for the installation (e.g., 7.4).java_version
:
The java version to install (e.g., 11). Note, that the installation of Java is required for Opencast and that for Opencast 13 and newer JDK 11 is supported only (state on 01/24/2023).opencast_version
:
The stable Opencast major version to install (e.g., 13 (see https://opencast.org/category/releases/)). Note, that the passed version must be at least 13.moodle_version
:
The version of the Moodle stable branch (e.g., 400 for Moodle 4.0).branch_moodle_plugins_opencast
:
The branch of the Opencast Moodle Plugins (this parameter is optional, e.g., Release_v4.0).
Note, that a summarized list of properties of this setup is given at the end of a successful execution of this script.
The directory scripts contains additional helper scripts without parameters, which must be run as superuser on the VM, that define the parameters for the script scripts/setup_moodle_system_with_opencast.sh and run it with those defined parameters:
- setup_moodle_400_system_with_opencast_13_plugins_release_400.sh:
Installs Moodle 4.0 and Opencast 13 as well as configures them. For this process, PHP 7.4 and Java 11 are installed as well as used. Furthermore, the branch of the Opencast Moodle Plugins is changed to Release_v4.0. - setup_moodle_401_system_with_opencast_13_plugins_release_401.sh:
Installs Moodle 4.1 and Opencast 13 as well as configures them. For this process, PHP 8.1 and Java 11 are installed as well as used. Furthermore, the branch of the Opencast Moodle Plugins is changed to Release_v4.1.