| | 1 | == Practice Moodle in VirtualBox |
| | 2 | |
| | 3 | ** Step-by-Step Guide to Share Alpine Linux `.OVA` File with Moodle Preconfigured ** |
| | 4 | |
| | 5 | This guide explains how to set up a `.vdi` file with Alpine Linux, configure it for sharing, and provide instructions for others to use it in VirtualBox. |
| | 6 | |
| | 7 | --- |
| | 8 | |
| | 9 | === **Part 1: Step-by-Step Instructions for Users** |
| | 10 | |
| | 11 | ==== **1. Download and Install VirtualBox**: |
| | 12 | 1. Visit [VirtualBox’s official site](https://www.virtualbox.org/). |
| | 13 | 2. Download the latest version for your operating system (Windows/macOS/Linux). |
| | 14 | 3. Install VirtualBox using the default options. |
| | 15 | --- |
| | 16 | ==== **2. Download the `.ova` File**: |
| | 17 | 1. Open the Google Drive link provided: |
| | 18 | ``` |
| | 19 | https://drive.google.com/file/d/1bun_iIx-RaQINks6RFgXBHM8kWDEhaAq/view?usp=sharing |
| | 20 | ``` |
| | 21 | 2. Download the `.ova file. |
| | 22 | --- |
| | 23 | ==== **3. Import the .ova File**: |
| | 24 | |
| | 25 | 1. Launch VirtualBox: |
| | 26 | - Open VirtualBox from your Start Menu, Applications, or Dock. |
| | 27 | 2. Import the Appliance: |
| | 28 | - Go to File > Import Appliance from the VirtualBox menu bar. |
| | 29 | 3. Browse to the .ova File: |
| | 30 | - Click on the folder icon to open the file picker. |
| | 31 | - Locate and select the .ova file you want to import. |
| | 32 | 4. Review Appliance Settings: |
| | 33 | - Click Next after selecting the file. |
| | 34 | - Review the virtual machine settings, including CPU, memory, and network. |
| | 35 | 5. Import the Appliance: |
| | 36 | - Click Import to start the process. |
| | 37 | - Wait for VirtualBox to import the .ova file. This might take a few minutes. |
| | 38 | |
| | 39 | --- |
| | 40 | ==== **4. Start the Virtual Machine**: |
| | 41 | 1. Click **Start** in VirtualBox. |
| | 42 | 2. Log in using: |
| | 43 | - **Username**: `moodle` |
| | 44 | - **Password**: `mdl@123` |
| | 45 | --- |
| | 46 | ==== **5. Find the VM IP Address**: |
| | 47 | 1. Inside the VM, type: |
| | 48 | ```bash |
| | 49 | ip addr |
| | 50 | ``` |
| | 51 | 2. Note the IP address (e.g., `192.168.1.10`). |
| | 52 | |
| | 53 | ==== **6. Map Moodle to a Hostname on Host Machine**: |
| | 54 | - On the host machine, edit the `hosts` file to map the VM's IP to a hostname. |
| | 55 | |
| | 56 | --- |
| | 57 | |
| | 58 | ==== **Edit Hosts File** |
| | 59 | |
| | 60 | ==== **Windows**: |
| | 61 | 1. Path: |
| | 62 | `C:\Windows\System32\drivers\etc\hosts` |
| | 63 | 2. Open Notepad as an administrator and add your VM IP: eg: |
| | 64 | ``` |
| | 65 | 192.168.1.10 mymoodle.test.learn.ac.lk |
| | 66 | ``` |
| | 67 | |
| | 68 | ==== **MacOS**: |
| | 69 | 1. Path: |
| | 70 | `/private/etc/hosts` |
| | 71 | 2. Open a terminal and edit the file: |
| | 72 | ```bash |
| | 73 | sudo nano /private/etc/hosts |
| | 74 | ``` |
| | 75 | 3. Add: |
| | 76 | ``` |
| | 77 | 192.168.1.10 mymoodle.test.learn.ac.lk |
| | 78 | ``` |
| | 79 | |
| | 80 | ==== **Linux**: |
| | 81 | 1. Path: |
| | 82 | `/etc/hosts` |
| | 83 | 2. Edit the file with: |
| | 84 | ```bash |
| | 85 | sudo nano /etc/hosts |
| | 86 | ``` |
| | 87 | 3. Add: |
| | 88 | ``` |
| | 89 | 192.168.1.10 mymoodle.test.learn.ac.lk |
| | 90 | ``` |
| | 91 | |
| | 92 | --- |
| | 93 | |
| | 94 | ==== **7. Access Moodle from the Host Machine**: |
| | 95 | 1. Open a browser on the host machine. |
| | 96 | 2. Navigate to: |
| | 97 | ``` |
| | 98 | http://mymoodle.test.learn.ac.lk |
| | 99 | ``` |
| | 100 | |
| | 101 | --- |
| | 102 | |
| | 103 | ==== Notes for Users: |
| | 104 | - Ensure VirtualBox's network settings are set to **Bridged Adapter**. |
| | 105 | - Ensure the VM is running before accessing Moodle. |
| | 106 | - Default credentials for the VM: |
| | 107 | - **Username**: `moodle` |
| | 108 | - **Password**: `Mdl@1234` |
| | 109 | |
| | 110 | This guide ensures users can easily import the `.vdi` file, configure the VM, and start practicing Moodle without additional setup. |
| | 111 | |
| | 112 | --- |
| | 113 | |
| | 114 | ==== **Part 2: Troubleshooting** |
| | 115 | |
| | 116 | Site Not Loading Properly: |
| | 117 | |
| | 118 | Verify nginx and php-fpm services are running: |
| | 119 | ``` bash |
| | 120 | rc-service nginx restart |
| | 121 | rc-service php-fpm82 restart |
| | 122 | ``` |
| | 123 | Ensure proper permissions for `moodledata:` |
| | 124 | ``` bash |
| | 125 | |
| | 126 | chmod -R 777 /var/www/moodledata |
| | 127 | ``` |
| | 128 | Error Messages: |
| | 129 | |
| | 130 | Check logs: |
| | 131 | ``` bash |
| | 132 | |
| | 133 | tail -f /var/log/nginx/error.log |
| | 134 | ``` |
| | 135 | |
| | 136 | Renew DHCP Lease on Alpine Linux |
| | 137 | ``` bash |
| | 138 | /etc/init.d/networking restart |
| | 139 | ``` |
| | 140 | then follow [Step 5](https://github.com/LEARN-LK/lms/blob/master/Practice-Moodle-VirtualBox.md#5-find-the-vm-ip-address) |
| | 141 | |
| | 142 | ==== plugin installation Troubleshooting |
| | 143 | |
| | 144 | Edit config.php in the Moodle directory: |
| | 145 | // Add these lines at the end of config.php: |
| | 146 | ``` bash |
| | 147 | @error_reporting(E_ALL | E_STRICT); |
| | 148 | @ini_set('display_errors', '1'); |
| | 149 | $CFG->debug = (E_ALL | E_STRICT); |
| | 150 | $CFG->debugdisplay = 1; |
| | 151 | ``` |
| | 152 | |
| | 153 | ==== 1. Update PHP-FPM User and Group |
| | 154 | Open the PHP-FPM pool configuration file: |
| | 155 | ``` bash |
| | 156 | vi /etc/php82/php-fpm.d/www.conf |
| | 157 | ``` |
| | 158 | ``` bash |
| | 159 | user = nginx |
| | 160 | group = nginx |
| | 161 | ``` |
| | 162 | ==== Restart PHP-FPM |
| | 163 | |
| | 164 | ``` bash |
| | 165 | rc-service php-fpm82 restart |
| | 166 | ``` |
| | 167 | ==== Set Permission "$CFG->directorypermissions = 0777;" |
| | 168 | ``` bash |
| | 169 | vi /var/www/moodle/config.php |
| | 170 | ``` |