Here are the steps to install Moodle on Debian/Ubuntu
sudo apt update
sudo apt upgrade
sudo apt install apache2 php libapache2-mod-php php-cli php-mysql php-gd php-xml php-curl php-zip php-mbstring php-soap
sudo apt install mariadb-server
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
exit;
Replace password with a strong password of your choice.
cd /tmp
wget https://download.moodle.org/stable/*version*/moodle-*version*.tgz
sudo tar -zxvf moodle-*version*.tgz -C /var/www/html/
sudo mv /var/www/html/moodle-*version* /var/www/html/moodle
sudo chown -R www-data:www-data /var/www/html/moodle/
sudo chmod -R 755 /var/www/html/moodle/
Replace *version* with the version number of the latest stable release.
sudo nano /etc/apache2/sites-available/moodle.conf
Add the following configuration:
<VirtualHost *:80>
ServerAdmin admin@linux-server-admin.com
DocumentRoot /var/www/html/moodle
ServerName linux-server-admin.com
ServerAlias www.linux-server-admin.com
<Directory /var/www/html/moodle>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/moodle_error.log
CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined
</VirtualHost>
Replace admin@example.com with your email address and example.com with your domain name or server IP address.
Save and close the file.
sudo a2ensite moodle.conf
sudo systemctl restart apache2
That’s it! You have successfully installed Moodle on Ubuntu.
Install Docker: First, you need to [install docker on your machine]((/software/container/docker/setup).
Get the Moodle image: Once Docker is installed, you can get the official Moodle image from the Docker Hub. You can pull the image using the following command:
docker pull moodlehq/moodle-php-apache:latest
This command will download the latest version of the Moodle image.
Create a Docker volume: You need to create a Docker volume to store the Moodle data. You can create a volume using the following command:
docker volume create moodledata
This will create a volume named moodledata that you can use to store your Moodle data.
Start the Moodle container: You can start the Moodle container using the following command:
docker run --name moodle -p 80:80 -v moodledata:/var/www/html -d moodlehq/moodle-php-apache:latest
This command will start a new container named moodle, bind port 80 of the container to port 80 of the host machine, mount the moodledata volume to the /var/www/html directory in the container, and run the latest version of the Moodle image in detached mode.
Access Moodle: You can access Moodle by visiting http://localhost in your web browser.
That’s it! You now have Moodle running in a Docker container.
If you want to setup Moodle in a docker Container with or without docker-compose see this guides: