Back to Blog
PHP Development

AlmaLinux 9 in WSL2 : install PHP, Apache, MariaDB, Composer, PhpMyadmin

In this article we will demonstrate how we install AlmaLinux 9 using Windows Subsystem for Linux (WSL2).

First, you need to check if your machine is ready for using WSL2. Open Windows Terminal and execute the following command:

wsl -v

The output should look similar to this:

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.3737

If instead of the above output, you get an error, it means that WSL is not (completely) installed on your machine. In this case, please follow the instructions found in this guide, then return to this page and continue with the next step.

Download and Install AlmaLinux 9

Open Microsoft Store and search for AlmaLinux. From the results, select AlmaLinux 9 and install it. Once installed, clicking on Open will open it in Windows Terminal.

The installer will prompt you for your username, your password and password confirmation.

Setup AlmaLinux 9

While still in the AlmaLinux 9 terminal, start executing the following commands.

Install required packages:

sudo dnf install epel-release dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y

Update installed packages:

sudo dnf upgrade -y

Install Ansible:

sudo dnf install ansible -y

Clone our development environment setup package:

git clone https://github.com/dotkernel/development.git

Navigate to the directory with the Ansible recipes:

cd ~/development/wsl/

Using your preferred text editor, open config.yml where you must fill in the empty fields. Save and close the file.

Run Step 1 of the installer script (it will prompt you for the password you entered during the installation process):

ansible-playbook -i hosts install.yml --ask-become-pass

Restart AlmaLinux 9:

  • press Control + d
  • Open Windows Terminal
  • stop AlmaLinux 9 by executing wsl -t AlmaLinux9
  • start AlmaLinux 9 by executing wsl -d AlmaLinux9

Navigate back to the directory with the Ansible recipes:

cd ~/development/wsl/

Run Step 2 of the installer script (once again, it will prompt you for the password you entered during the installation process):

ansible-playbook -i hosts install.yml --ask-become-pass

Once finished, the installation is complete, your AlmaLinux 9 development environment is ready to use.

Test AlmaLinux 9

Check if everything works by opening in your browser:

The complete guide with additional features is available here.

Frequently Asked Questions

How do I check if my machine is ready for WSL2? +

Open Windows Terminal and run wsl -v. If it returns version information (WSL, Kernel, WSLg, MSRDC, Direct3D, DXCore, Windows versions), WSL2 is installed. If you get an error instead, WSL is not completely installed and you need to follow the linked setup guide first.

How do I download and install AlmaLinux 9? +

Open Microsoft Store, search for AlmaLinux, select AlmaLinux 9 from the results, and install it. Once installed, clicking Open launches it in Windows Terminal, where the installer prompts for your username, password, and password confirmation.

What are the main setup steps inside AlmaLinux 9? +

Install epel-release, dnf-utils and the Remi repository RPM, upgrade installed packages, install Ansible, clone the dotkernel/development Git repository, navigate to its wsl directory, fill in the empty fields in config.yml, then run the installer script's Step 1 with ansible-playbook -i hosts install.yml --ask-become-pass (it will prompt for the password set during installation).

Why do I need to restart AlmaLinux 9 partway through setup? +

After Step 1 of the installer script, you press Control+D, open Windows Terminal, stop AlmaLinux 9 with wsl -t AlmaLinux9, and start it again with wsl -d AlmaLinux9. Then you navigate back to the Ansible recipes directory and run Step 2 of the installer script (again with ansible-playbook -i hosts install.yml --ask-become-pass), which prompts for the password again. Once Step 2 finishes, the AlmaLinux 9 development environment is ready.

How do I verify the installation worked? +

Check three URLs in your browser: http://localhost/ for Apache's default home page, http://localhost/info.php for the PHP info page, and http://localhost/phpmyadmin/ for PhpMyAdmin, logging in with username root and the root password configured in config.yml under mariadb -> root_password.