You can now install and run Drupal CMS directly from Windows 11 via Windows Subsystem for Linux (WSL) without installing third-party apps or using a virtual machine. Back in 2017, Microsoft released WSL and later WSL2 which lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot. WSL2 is the new and improved version that 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. With Windows 11, installing WSL is a bit different than in Windows 10. However, the steps below are going to show you how to do that. To install and run Drupal on Windows 11 you must first install and enable WSL.
Install Windows Subsystem for Linux in Windows 11
To enable WSL in Windows, you will want to open the Command Prompt as administrator. Click on Start then begin typing Command Prompt. Next, right-click Command Prompt app and choose to Run as administrator. When the console opens, run the commands below to install Windows Subsystem for Linux (WSL): Wait for WSL to be installed. After installing, you should get a success message similar to the lines below: Restart your computer. WSL should be installed and ready to use. When you want to update, simply run the commands below:
Install Specific Linux distro on Windows 11
Now that WSL is installed, you can now install the Linux distro of your choice. To list the available distributions to install, simply run the commands below: You should then see all available distributions that can be installed on WSL. To install a Linux distribution from the list above, simply run the commands below using the distribution name. For example, to install Ubuntu 20.04, run the commands below: You should then get a message that the distribution is installed. After installing, you should get a Ubuntu command console with setup details. Some troubleshooting commands to run when you run into issues. Now that Ubuntu Linux is installed and ready to use, continue below to install the LEMP server to run Drupal on. First, install Nginx HTTP Server.
Install Nginx HTTP Server
Drupal requires a web server to function, and Nginx is one of the most popular open-source web servers available today. To install Nginx on Ubuntu, run the commands below: After installing Nginx, the commands below can be used to stop and start Nginx services. To test whether Nginx is installed and functioning, open your web browser and browse to the server’s IP address or hostname. http://localhost If you see the above page in your browser, then Nginx is working as expected.
Install MariaDB Server
You’ll also need a database server to run Drupal. A database server is where Drupal content gets stored. 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: After installing MariaDB, the commands below can be used to stop, start and enable the MariaDB service always to start up when the server boots. 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.
Install PHP and Related Modules
Drupal is a PHP-based application, and PHP is required to run it. Run the commands below to install PHP and related modules to support Drupal. After installing PHP, go and configure some basic settings that may be required for Drupal to function properly. For this tutorial, PHP 7.4 was installed. Based on your environment, another version of PHP might be installed. So verify that. Below are good settings to configure for most Drupal websites. 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.
Create Drupal Database
When all the servers are installed above, it’s now time to begin setting up the Drupal environment. First, run the steps below to create a blank database for Drupal to use. Login to the MariaDB database console using the commands below: Then create a database called drupaldb Next, create a database user called drupal user and set a password Then grant the user full access to the database. Finally, save your changes and exit.
Download Drupal
At this point, Drupal is ready to be downloaded and installed. Use the commands below to download the latest version of Drupal. To get Drupal’s latest release you may want to use the GitHub repository… Install Composer, Curl and other dependencies to get started… 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. Then run the command below to allow the www-data user to own the Drupal directory.
Configure Nginx VirtualHost
Below is where you configure the Nginx VirtualHost file for the Drupal 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 Drupal in the /etc/nginx/sites-available/ directory. A very good configuration setting for most Drupal sites on the Nginx 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 Nginx server. At this stage, Drupal is ready and can be launched by going to the server’s IP or hostname. That should bring up the Drupal setup wizard. Type in the database connection and continue Create a Drupal admin account and password, save and continue. Log in with the account above and you’re done. 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.