Setting up WSL on Windows 11 for Drupal 11 development

By admin_norgaard, 17 August, 2024
Setting up WSL on Windows 11 for Drupal 11 development

Coming from an Ubuntu Linux background, I’m all about that streamlined development environment, but let's be real - sometimes you need to game, listen to music, and hop on a few meetings without juggling multiple devices. Enter the gaming PC: a powerhouse that lets me keep work and play separate. But don’t worry, Linux still has a seat at the table.

When I switched to Windows 11, I wanted to keep my Linux efficiency while also diving into the sweet world of gaming. WSL (Windows Subsystem for Linux) was the perfect bridge between these two worlds, letting me enjoy my Linux workflows without giving up the joys of PC gaming.

WSL allows me to run a full Ubuntu environment right inside Windows. This means I can use all the tools I loved on Linux, minus the mess of WAMP or XAMPP - those dinosaurs should be extinct by now. With WSL, I can run my entire Drupal stack natively, with Linux commands and scripts, just like the good old days on Ubuntu. No need to deal with the ghosts of local development past!

To make life even smoother, I set up a shortcut to launch WSL without needing admin rights:

  1. Create the shortcut:
    • Right-click on the desktop, select New > Shortcut.
    • Set the location to C:\Windows\System32\wsl.exe.
    • Name the shortcut (something cool like "WSL Terminal") and click Finish.
  2. Assign a keyboard shortcut:
    • Right-click the shortcut, go to Properties.
    • In the Shortcut tab, click the Shortcut key field and press Ctrl + Alt + T.
    • Click Apply, then OK.

Now, with a quick keyboard shortcut, I can dive straight into my WSL environment, keeping development fast and efficient. It’s like having the best of both worlds: the power and familiarity of Linux for development and the gaming prowess of Windows 11 for, well, everything else.

No more fighting with WAMP or XAMPP—just a clean, effective, and powerful way to develop Drupal locally.

 


Quick Start: Setting Up Ubuntu on WSL for Drupal Development

Quick Start: Setting Up Drupal with DDEV on WSL

Say goodbye to those clunky local setups - here’s how to set up your Drupal development environment using DDEV on Ubuntu within WSL. It’s the modern way to do things, leaving WAMP, XAMPP, and their outdated friends in the dust.

  1. Install WSL and Ubuntu 22.04 LTS:

    • Open PowerShell as admin and run:
    wsl --install
    • This installs WSL along with the default Ubuntu distribution. If you want the latest Ubuntu 22.04 LTS, just ensure it’s updated after installation. Restart your machine if prompted.
  2. Set up Docker and DDEV:

    • Launch Ubuntu from the Start menu or by typing wsl in your terminal.
    • Install Docker by following the official Docker on Ubuntu guide. Make sure Docker is up and running within WSL.
    • Install DDEV using the official script:
    sudo apt-get install -y bash-completion apt-transport-https ca-certificates software-properties-common
    curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash
  3. Create your Drupal project:

    • Navigate to your project directory:
    cd ~/projects
    • Set up a new Drupal project using DDEV:
    ddev config --project-type=drupal9 --docroot=web --create-docroot
    ddev start
    • Install Drupal using Drush:
    ddev drush site:install
  4. Access your Drupal site:
    • Once DDEV has started your project, access your Drupal site by navigating to https://<projectname>.ddev.site in your web browser.
  5. Forget the clunky old stacks:
    • With DDEV on WSL, you’re running a modern, containerized development environment that’s fast, flexible, and easy to manage. No more fighting with outdated local setups!

Now you're ready to develop Drupal like a pro, using the best tools for the job. DDEV and WSL together offer a powerful, efficient setup that leaves those old local development methods in the dust. Happy gaming and coding!