Moodle is an open-source, mobile-friendly learning management system (LMS) that makes it easy to create and distribute your courses and training materials for any purpose. You can use Moodle to power your online course and learning websites with ease, without the need to learn how to read and write complicated codes and scripts. Now that you can install Linux OS inside Windows via WSL, the steps below show you how to install Moodle in Windows with Windows Subsystem for Linux (WSL). With WSL, you can install and run a full Linux operating system inside Windows. So get Windows, enable WSL, install a Linux OS and run Moodle. Back in 2017, Windows released the original WSL version. WSL 2 is an improvement over version 1 and comes with a performance boost, and full system call compatibility, and is built with a new architecture that delivers features that make WSL an amazing way to run a Linux environment in Windows. If you have a machine that meets the requirements above to run WSL 2, then continue below. To get started with running Moodle on Windows with WSL, follow the steps below:

Enable WSL in Windows

To enable WSL in Windows, you will want to open the PowerShell terminal as administrator. Click on Start then begin typing PowerShell. Next, right-click the Windows PowerShell app and choose to run as administrator. When the console opens, run the commands below: After installing, you should get a success message similar to the lines below:

Enable Virtual Machine Platform

WSL 2 requires Windows 10 Virtual Machine Platform to be enabled. This is not Hyper-V. To enable the VM platform feature in Windows, run the commands below from the same PowerShell administrator’s console. If you’re using Windows 10 version lower than 2004, then use the commands below: When you’re done running the commands above, restart your computer for all the configuration changes to apply. If you don’t restart, the below command might not be recognized. After restarting your computer, login back in and launch PowerShell as administrator. Then run the commands below to configure WSL 2 as the default version of WSL.

Install Ubuntu on Windows 10

Now that WSL 2 is installed and ready to be used, open the link below to download and install a copy of Ubuntu 20.04 from the Windows store. Get Ubuntu 20.04 LTS – Microsoft Store Ubuntu 20.04 LTS on Windows allows you to use Ubuntu Terminal and run Ubuntu command line utilities including bash, ssh, git, apt, and many more. Click the Get button and install. After installing Ubuntu, you’ll want the option to launch Ubuntu from the Windows WSL environment. After launching Ubuntu, it should install and prompt you to create your account. That should do it! Some troubleshooting commands to run when you run into the issues above. These run below and try to launch the Ubuntu image again. Now that Windows 10 WSL environment is ready, continue below to install Apache, MariaDB, and PHP and configure Moodle to run.

Install Apache HTTP Server

Apache is the most popular open-source web server powering the majority of websites online. Since Moodle needs it, use the commands below to install it on Ubuntu. To install Apache on Ubuntu, run the commands below: After installing Apache2, the commands below can be used to stop, start and restart Apache2 services. To validate that Apache is installed and functioning, open your web browser and browse to the server’s hostname or IP address. You should get a test page if every works. http://localhost

Install MariaDB Database Server

For this tutorial, we’re going to be installing MariaDB. Moodle needs a database server to store its content. MariaDB is a truly open-source database server you can run with your projects. It is fast, secure and the default server for almost all Linux. To install MariaDB, run the commands below: After installing MariaDB, the commands below can be used to stop, start and restart MariaDB services. Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation. When prompted, answer the questions below by following the guide.

Enter current password for root (enter for none): Just press the Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]:  Y Reload privilege tables now? [Y/n]:  Y

To verify and validate that MariaDB is installed and working, log in to the database console using the commands below: Type the root password when prompted. If you see a similar screen as shown above, then the server was successfully installed.

PHP is a general-purpose scripting language that glues all the above components together. Moodle is a PHP application and requires PHP and related modules to function. To install PHP and recommended modules, run the commands below. That should get PHP installed with recommended PHP modules that you can run with many PHP-based applications. To validate that PHP is installed, run the commands below: You should see an output like the one below: You can also test with a test PHP script and display the installed version as well as related modules that are enabled or disabled. To do that, run the commands below to create a PHP test file called phpinfo.php Then type the content below and save the file. Save the file. Open your browser and browse to your server hostname followed by phpinfo.php Restart Apache, then type the address and browse the file. You should see the PHP default test page. At this stage, all required components that Moodle needs are installed above. Continue below to download and configure Moodle settings.

Create Moodle Database

When all the servers are installed above, it’s now time to begin setting up Moodle environment. First, run the steps below to create a blank database for Moodle to use. Login to the MariaDB database console using the commands below: Then create a database called moodle Next, create a database user called moodleuser and set password Then grant the user full access to the database. Finally, save your changes and exit.

Download Moodle

At this point, Moodle is ready to be downloaded and installed. Use the commands below to download the latest version of Moodle. At the time of this writing, the latest version is 39. To view Moodle releases, see this page. After installing git and curl above, change into the Apache root directory and download Moodle packages from GitHub. Always replace the branch number with the latest branch. Then run the commands below to set the correct permissions for Moodle to function.

Configure Apache

Below is where you configure the Apache VirtualHost file for the Moodle site you’re creating. This file defines how client requests are handled and processed. Run the commands below to create a new VirtualHost file called moodle. conf in the /etc/apache2/sites-available/ directory. A very good configuration setting for most Moodle sites on the Apache server is below. This configuration should work great. Copy the content below and save it into the file created above. Save the file and exit. After saving the file above, run the commands below to enable the new site, then restart the Apache server. At this stage, Moodle is ready and can be launched by going to the server’s IP or hostname. Moodle installation wizard should open and you can follow. Choose the installation language and continue. Confirm Moodle directory structure. Moodle directory: The full path to the directory containing the Moodle code. Data directory: A directory where Moodle will store all file content uploaded by users. Moodle supports several types of database servers. Please contact the server administrator if you do not know which type to use. Type in the database name, username, and password to connect to the database created above. Validate other checks and requirements and continue with the installation wizard. On this page, you should configure your main administrator account which will have complete control over the site. Make sure you give it a secure username and password as well as a valid email address. You can create more admin accounts later on. After that, Moodle should be installed and ready to use. Conclusion: This post showed you how to install Moodle in Windows WSL. If you find any error above, please use the comment form below to report.