Skip to content
Follow
CMS Windows

How to Install Drupal with WSL on Windows 11

Richard
Written by
Richard
Jul 22, 2021 Updated Jun 20, 2026 9 min read
How to Enable Voice Access on Windows 11 Sign-In
How to Enable Voice Access on Windows 11 Sign-In

You install Drupal with WSL on Windows 11 by enabling the Windows Subsystem for Linux and then setting up Drupal within that Linux environment.

WSL lets you run a Linux distribution, like Ubuntu, directly on your Windows 11 PC. This is ideal for web developers who want to use tools like Drupal without a separate virtual machine.

Microsoft first launched WSL in 2017, with WSL2 significantly improving performance and compatibility. Using WSL2 ensures a smooth experience for running Drupal.

This guide shows you how to get Drupal CMS running on your Windows 11 machine using WSL2, typically in just a few minutes for the initial WSL setup.

⚡ Quick Answer

Install the Windows Subsystem for Linux by opening Command Prompt as administrator and running “wsl –install.” After restarting, install a Linux distribution like Ubuntu using “wsl –install -d ubuntu-20.04.

Install Windows Subsystem for Linux in 🪟 Windows 11

Installing the Windows Subsystem for Linux (WSL) on Windows 11 lets you run Linux tools directly on your PC. You’ll need to open the Command Prompt as an administrator to start the process.

Next, right-click the Command Prompt app and choose to Run as administrator.

Command Prompt running as administrator on Windows 11
windows 11 command prompt administrator

When the console opens, run the commands below to install Windows Subsystem for Linux (WSL):

💻Code
wsl --install

Wait for WSL to be installed.

After installing, you should get a success message similar to the lines below:

💻Code
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Downloading: WSL Kernel
Installing: WSL Kernel
WSL Kernel has been installed.
Downloading: GUI App Support
Installing: GUI App Support
GUI App Support has been installed.
Downloading: Ubuntu
The requested operation is successful. Changes will not be effective until the system is rebooted.

Restart your computer.

WSL should be installed and ready to use. When you want to update, run the commands below:

💻Code
wsl --update

Install Specific Linux distro on 🪟 Windows 11

After installing WSL, you can choose and install a specific Linux distribution like Ubuntu or Debian on your Windows 11 machine. Running ‘wsl –list –online’ shows you all the available options to pick from.

💻Code
wsl --list --online

You should then see all available distributions that can be installed on WSL.

💻Code
NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

To install a Linux distribution from the list above, run the commands below using the distribution name. For example, to install Ubuntu 20.04, run the commands below:

💻Code
wsl --install -d ubuntu-20.04

You should then get a message that the distribution is installed.

💻Code
Downloading: Ubuntu 20.04 LTS
Installing: Ubuntu 20.04 LTS
Ubuntu 20.04 LTS has been installed.
Launching Ubuntu 20.04 LTS.

After installing, you should get a Ubuntu command console with setup details.

💻Code
Installing, this may take a few minutes.
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: Richard
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.4.0-22000-Microsoft x86_64)

Some troubleshooting commands to run when you run into issues.

💻Code
wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Now that Ubuntu Linux is installed and ready, continue below to install the LEMP server to run Drupal. First, install the Nginx HTTP Server.

Install Nginx HTTP Server

Drupal needs a web server to work, and Nginx is a popular choice for serving websites. To install Nginx on your WSL Linux distribution, you’ll use a couple of simple commands in the terminal.

To install Nginx on Ubuntu, run the commands below:

🐧Bash / Shell
sudo apt update
sudo apt install nginx

After installing Nginx, the commands below can be used to stop and start Nginx services.

🐧Bash / Shell
sudo service nginx stop
sudo service nginx start

To test whether Nginx is installed and functioning, open your web browser and browse to the server’s IP address or hostname.

http://localhost

Installing Ubuntu and Nginx on Windows WSL
windows wsl ubuntu nginx install

If you see the above page in your browser, Nginx works as expected.

Install MariaDB Server

Drupal stores all its content in a database, and MariaDB is a great, fast, and secure option for this. Installing the MariaDB server and client on your WSL Linux system is straightforward with a single command.

A truly open-source database server that you can use with Drupal is the MariaDB database server. It is fast, secure, and the default server for almost all Linux servers.

To install MariaDB, run the commands below:

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

After installing MariaDB, the commands below can stop, start, and enable the service to start when the server boots.

🐧Bash / Shell
sudo service mysql stop
sudo service mysql start
⚠️Warning
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.
🐧Bash / Shell
sudo mysql_secure_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:

🐧Bash / Shell
sudo mysql -u root -p

Type the root password when prompted.

mariadb welcome
mariadb ubuntu 1604

The server was successfully installed if you see a similar screen.

Since Drupal is built with PHP, you need to install PHP and several specific modules to make it run correctly on your WSL setup. A single command installs PHP and all the necessary extensions for Drupal.

🐧Bash / Shell
sudo apt install php-fpm php-common php-mysql php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

After installing PHP, configure some basic settings required for Drupal to function properly.

📝Good to Know
For this tutorial, PHP 7.4 was installed. Based on your environment, another version of PHP might be installed. So verify that.
🐧Bash / Shell
sudo nano /etc/php/7.4/fpm/php.ini

Below are good settings to configure for most Drupal websites.

💻Code
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

That should get PHP 7.4 installed with some basic settings to allow Drupal to function.

After setting up PHP, the command below can be used to stop and start PHP7.4 services.

🐧Bash / Shell
sudo service php7.4-fpm stop
sudo service php7.4-fpm start

Create Drupal Database

With your web and database servers ready, you can now create a dedicated database for your Drupal installation. You’ll log into the MariaDB console and create a new database specifically for Drupal to use.

Login to the MariaDB database console using the commands below:

🐧Bash / Shell
sudo mysql -u root -p

Then, create a database called drupaldb

💻Code
CREATE DATABASE drupaldb;

Next, create a database user called Drupal user and set a password

💻Code
CREATE USER 'drupaldbuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then, grant the user full access to the database.

💻Code
GRANT ALL ON drupaldb.* TO 'drupaldbuser'@'localhost' WITH GRANT OPTION;

Finally, save your changes and exit.

💻Code
FLUSH PRIVILEGES;
EXIT;

Download Drupal

Now that your environment is set up, it’s time to download the latest version of Drupal itself. You’ll use commands to install helpful tools like Composer and then download Drupal to your WSL system.

To get Drupal’s latest release, you may want to use the GitHub repository… Install Composer, Curl, and other dependencies to get started…

🐧Bash / Shell
sudo apt install curl git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

After installing curl and Composer above, change into the Nginx root directory and download Drupal packages from GitHub… Always replace the branch number with the latest branch.

To view Drupal releases, see this page.

Command Prompt
cd /var/www/
sudo git clone --branch 9.1.9 https://git.drupal.org/project/drupal.git
cd /var/www/drupal
sudo composer install

Then, run the command below to allow the www-data user to own the Drupal directory.

🐧Bash / Shell
sudo chown -R www-data:www-data /var/www/drupal/
sudo chmod -R 755 /var/www/drupal/

Configure Nginx VirtualHost

To make your Drupal site accessible through Nginx, you need to set up a VirtualHost configuration file. This file tells Nginx how to handle requests for your specific Drupal installation within WSL.

Run the commands below to create a new VirtualHost file called Drupal in the /etc/nginx/sites-available/ directory.

🐧Bash / Shell
sudo nano /etc/nginx/sites-available/drupal

Below is a very good configuration setting for most Drupal sites on the Nginx server. This configuration should work great.

Copy the content below and save it into the file created above.

🐘PHP
server {
    listen 80;
    listen [::]:80;
    root /var/www/drupal;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com;

    client_max_body_size 100M;
    autoindex off;

    location ~ .*/.*.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Block access to scripts in site files directory
    location ~ ^/sites/[^/]+/files/.*.php$ {
        deny all;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/). {
        return 403;
    }

    location / {
        try_files $uri /index.php?$query_string;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*.php$ {
        deny all;
        return 404;
    }

    location ~ '.php$|^/update.php' {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Fighting with Styles? This little gem is amazing.
    # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
    location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
        try_files $uri @rewrite;
    }

    # Handle private files through Drupal. Private file's path can come
    # with a language prefix.
    location ~ ^(/[a-z-]+)?/system/files/ { # For Drupal >= 7
        try_files $uri /index.php?$query_string;
    }
}

Save the file and exit.

After saving the file above, run the commands below to enable the new site, then restart the Nginx server.

🐧Bash / Shell
sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/
sudo service nginx restart

At this stage, Drupal is ready and can be launched by going to the server’s IP or hostname.

💻Code
http://example.com

That should bring up the Drupal setup wizard.

Drupal installation process on Windows WSL
drupal windows wsl install

Type in the database connection and continue

Database connection setup for Drupal on WSL
drupal windows wsl database connection

Create a Drupal admin account and password, save, and continue.

Creating admin account for Drupal on Windows WSL
drupal windows wsl admin account

Log in with the account above, and you’re done.

Drupal dashboard interface on Windows WSL
drupal windows wsl dashboard

That’s it!

Conclusion:

This post showed you how to install Drupal on Windows 10 with Ubuntu. If you find any error above, please use the comment form below to report.

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 Windows Subsystem for Linux (WSL) on Windows 11
Ubuntu Linux How to Install Windows Subsystem for Linux (WSL) on Windows 11
How to install Drupal with Nginx on Ubuntu 24.04
CMS How to install Drupal with Nginx on Ubuntu 24.04
How to Uninstall Windows Subsystem for Linux (WSL) in Windows 11
Ubuntu Linux How to Uninstall Windows Subsystem for Linux (WSL) in Windows 11
How to Enable or Disable App Location Requests in Windows 11
Windows How to Enable or Disable App Location Requests 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 *