Skip to content
Follow
CMS

How to install Moodle with Apache on Ubuntu 24.04

Richard
Written by
Richard
Jun 1, 2024 Updated Jun 20, 2026 8 min read
Moodle featured image
Moodle featured image

You install Moodle with Apache on Ubuntu 24.04 to create your own powerful learning management system.

Moodle is a free, open-source e-learning platform for building and managing online courses. Apache is the web server that will serve your Moodle site to users.

This guide walks you through installing Moodle version 4.3, the latest stable release, on Ubuntu 24.04 LTS using Apache.

Following these steps lets you establish a robust and scalable platform for your educational needs, giving you full control over your online learning environment.

⚡ Quick Answer

Install Apache using `sudo apt install apache2`, then install MariaDB with `sudo apt install mariadb-server`. Create a Moodle database and user within MariaDB, and finally install PHP with `sudo apt install php libapache2-mod-php php-mysql php-intl`.

Install Apache HTTP server on Ubuntu Linux

To install the Apache web server on Ubuntu 24.04, open your terminal and run the commands ‘sudo apt update’ followed by ‘sudo apt install apache2’. Apache is needed to run Moodle and will be started automatically after installation.

To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.

🐧Bash / Shell
sudo apt update
sudo apt install apache2

Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2

You test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.

http://localhost

Apache2 default landing page displayed after installing Moodle on Ubuntu 24.04
Apache2 default landing page displayed after installing Moodle on Ubuntu 24.04

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.

Additional help on installing Apache on Ubuntu is in the link below.

How to install Apache on Ubuntu

Install MariaDB database server on Ubuntu Linux

You’ll need a database server for Moodle, and MariaDB is a great choice for Ubuntu 24.04. To install it, open your terminal and run ‘sudo apt update’ then ‘sudo apt install mariadb-server’.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Create a Moodle database

After installing MariaDB, you need to create a dedicated database for Moodle. We’ll create a database named ‘moodledb’ and a user ‘moodledbuser’, then give that user full access to the database.

As part of the setup, we will create a database named ‘moodledb ‘and a corresponding user account named ‘moodledbuser ‘.

Finally, we’ll grant the moodledbuser full access to the moodledb database.

All the database steps above can be done using the commands below:

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE DATABASE moodledb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER moodledbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON moodledb.* TO moodledbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Ensure to replace ‘type_your_password_here‘ with your password.

Install PHP on Ubuntu Linux

Moodle is built with PHP, so you need to install it on your Ubuntu 24.04 system. Run the command ‘sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-soap php-zip’ to get PHP and all the necessary modules.

Run the commands below to install PHP.

🐧Bash / Shell
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-soap php-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download Moodle files

Now, let’s get the Moodle files onto your Ubuntu server. You’ll download them and place them in the correct folder for Apache to use. First, create a new Moodle folder in the Apache root directory.

The command block below will download and create a new Moodle folder in the Apache root directory.

First, create a Moodle folder in the Apache root directory.

Next, navigate to the /tmp directory and download Moodle files. After unzipping the file, move the content into the Moodle folder you created in the Apache root directory.

Rest assured, the final step is to change the permissions. This will allow the Apache web server to safely interact with the files, ensuring a secure environment for your Moodle installation.

Stay up-to-date with Moodle’s latest version. Get it from the official download page and replace the link with the new version to ensure you benefit from the latest features and security updates.

Command Prompt
cd /tmp/
wget https://download.moodle.org/download.php/direct/stable404/moodle-4.4.zip
sudo unzip -d /var/www moodle-*.zip
sudo mkdir -p /var/www/moodledata
sudo chown -R www-data:www-data /var/www/moodledata/
sudo chown -R www-data:www-data /var/www/moodle/

Once you have completed all the above steps, continue below to configure the Apache web server to serve the Moodle content.

Run the commands below to create an Apache virtual host file for Moodle.

🐧Bash / Shell
sudo nano /etc/apache2/sites-available/moodle.conf

Then, copy and paste the content block below into the Apache server block.

💻Code
<VirtualHost *:80>
ServerName moodle.example.com
ServerAlias www.moodle.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/moodle

<Directory /var/www/moodle/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the file.

Then, run the commands below to enable the server block and restart the Apache server.

🐧Bash / Shell
sudo a2ensite moodle.conf
sudo systemctl restart apache2

Setup Let’s Encrypt SSL/TLS for Moodle

To make your Moodle site secure with HTTPS, you can set up a free SSL/TLS certificate using Let’s Encrypt. This guide will show you how to get and install a Let’s Encrypt certificate for Apache on Ubuntu.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.

How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux

Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.

💻Code
http://moodle.example.com

A Moodle installation wizard page should appear. Select the installation language and continue to the next page.

Moodle set up choose a language
Moodle set up choose a language

Confirm the installation paths and continue.

Moodle set up confirm paths
Moodle set up confirm paths

Next, choose a database driver (MariaDB) and continue.

Moodle set up choose database driver mariadb
Moodle set up choose database driver mariadb

On the next page, type in the database name, username, and password created above and continue.

Moodle set up choose database connection entries
Moodle set up choose database connection entries

Confirm all requirements are met and continue.

If you get an error message that “max_input_vars” must be at least 5000, run the command below to fix it. Ensure that it is applied to the correct PHP version installed.

🐧Bash / Shell
sudo sed -i "s/;max_input_vars = .*/max_input_vars = 5000/" /etc/php/8.3/apache2/php.ini
Moodle set up requirements check
Moodle set up requirements check

Next, set up your admin account and continue.

Moodle set up admin account
Moodle set up admin account

Your Moodle site should be set up and ready to use.

Moodle set up complete
Moodle set up complete

That should do it!

Conclusion:

  • This guide provides a comprehensive overview of installing Moodle with Apache support on Ubuntu 24.04. It incorporates essential components like the Apache web server, MariaDB database server, PHP, and Let’s Encrypt SSL/TLS for enhanced security.
  • The step-by-step tutorials for each component ensure a thorough understanding of the installation process, enabling users to create a reliable and robust environment for hosting their e-learning content.
  • By following these instructions, users can seamlessly set up a Moodle site on Ubuntu, leveraging the capabilities of Apache as the web server, MariaDB as the database server, and PHP for a smooth and versatile web application experience.
  • Including additional resources and links for each component further enriches the guide, empowering users to seek further assistance or explore specific aspects of the installation as needed.
  • Should readers encounter errors or wish to contribute additional insights, the comments section provides a platform for engaging in meaningful discussions and sharing valuable feedback.

Does Moodle use Apache?

Moodle is primarily developed in Linux using Apache, PostgreSQL/MySQL/MariaDB and PHP (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options (Nginx/OpenLiteSpeed) as long as the software requirements of the release are met.

How to install Moodle locally?

Next. It will then ask me for these i'll leave it as is everything as is. And then I'll click on.

How to check Moodle version in Linux?

The version of Moodle which your site is using can be found if you log in as an administrator and go to Site administration > Notifications.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install Apache on Ubuntu: A Step-by-Step Guide
Ubuntu Linux How to Install Apache on Ubuntu: A Step-by-Step Guide
Install Symfony 5 on Ubuntu with Apache
Ubuntu Linux Install Symfony 5 on Ubuntu with Apache
How to install Drupal with Apache support on Ubuntu 24.04
CMS How to install Drupal with Apache support on Ubuntu 24.04
How to Start, Stop, and Restart Services in Windows 11
Windows How to Start, Stop, and Restart Services in Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *