Moodle is an open-source platform used to create and manage online learning environments, such as websites for educational courses, training and development programs, and other online educational resources. NixOS is a Linux distribution that provides a reliable and secure operating system, with advanced package management capabilities.
In this tutorial, we will guide you step-by-step through the process of installing Moodle on NixOS Latest.
Before installing Moodle, we need to install some required packages that are needed to run the application. Run the following command to install necessary packages.
sudo nix-env -iA nixos.nginx php php-fpm mariadb
First, you need to create a directory to install Moodle. Run the following command to create a new directory named "moodle".
sudo mkdir /var/www/moodle
Download the latest stable version of Moodle from the official website using the following command.
sudo curl -o /var/www/moodle/moodle.tar.gz -L https://download.moodle.org/download.php/direct/stable310/moodle-latest-310.tgz
Replace the version number with the latest stable release number.
Extract the downloaded package using the following command.
sudo tar xzf /var/www/moodle/moodle.tar.gz -C /var/www/moodle/
Rename the extracted directory to "moodle".
sudo mv /var/www/moodle/moodle-* /var/www/moodle/moodle
Change the ownership of the Moodle directory to the nginx user.
sudo chown -R nginx:nginx /var/www/moodle/moodle
To configure Nginx, create a new file for Moodle virtual host.
sudo nano /etc/nginx/conf.d/moodle.conf
Add the following content to the file.
server {
listen 80;
server_name example.com;
root /var/www/moodle/moodle;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Replace "example.com" with your domain name or IP address.
Verify that the configuration file is valid with the following command.
sudo nginx -t
If the configuration file is valid, restart the Nginx service.
sudo systemctl restart nginx
To configure MariaDB, start the service.
sudo systemctl start mariadb
Create a new database for Moodle.
mariadb -u root -p
MariaDB [(none)]> CREATE DATABASE moodle;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'moodlepassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;
Replace the "moodleuser" and "moodlepassword" with your desired username and password.
Open the Moodle configuration file.
sudo nano /var/www/moodle/moodle/config.php
Change the following settings to match the MariaDB database settings.
$CFG->dbtype = 'mysqli';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodleuser';
$CFG->dbpass = 'moodlepassword';
$CFG->prefix = 'mdl_';
Replace the "moodleuser" and "moodlepassword" with your desired username and password.
Open a web browser and navigate to your domain name or IP address.
http://example.com
Replace "example.com" with your domain name or IP address.
Follow the instructions to complete the Moodle installation process.
Congratulations! You have successfully installed Moodle on NixOS Latest. You can now start creating your online learning resources within your newly installed Moodle instance.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!