Installing Drupal 9 in Windows

This is part of our Drupal Installation Guide

Setting up an environment for developing with Drupal 9 in Windows can be a challenge. We recommend two options for those who need access to the codebase (required for Theme and Module Development trainings).

Jump to a Drupal 9 Installation Method (Windows Only): 

Method 1: AMPPS
Method 2: Docksal/Lando

Method 1: AMPPS

This method is simpler to install, and has little base requirements. If you already have Acquia Dev Desktop, make sure you turn it off before installing AMPPS.

1. Download and run the installer:

2. Installation doesn't require any changes to default options. You may choose to install in the root folder (i.e. c:\Ampps) so it's easier to navigate in command-line.

3. When finished, you can go ahead and add a new App of type Drupal. Make sure you select 9 (should be the default version). You can fill in user credentials and click to install. Verify you have a working Drupal 9 site.

Setting up command line utilities with AMPPS

Although AMPPS is easy to install and setup a Drupal codebase, it doesn't come with out-of-the-box command line utilities. But we can easily add them:

1. Open Start Menu and type "Environment." You should see an entry for editing System Environment variables.

System Properties: Advanced

2. Click on Environment Variables. Find a variable under "User variables for [username]" called "Path" and click "Edit..."

screenshot: adding environment variables

3. Under the next screen, add this line on your Path variable (if you installed Ampps in a different folder, change this to the right one): "C:\Program Files\Ampps\php".

Editing Path variable

4. This step will allow you to run any binaries present in that folder, the most important being "php". Now open a new CMD prompt and type the following to install Composer.

> cd c:\Program Files\Ampps\php
> php -r "copy('', 'composer-setup.php');"
> php -r "if (hash_file('sha384', 'composer-setup.php') === 'e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
> php composer-setup.php
> php -r "unlink('composer-setup.php');"
> echo @php "%~dp0composer.phar" %*>composer.bat

5. Test this by running "composer" command, which should give you Composer's help page.

6. Next, type the following commands in the same prompt, to install Drush Launcher:

> curl -OL
> echo @php "%~dp0drush.phar" %*>drush.bat

7. You can test by running "drush" command, which should return a message saying Drush Launcher didn't find a Drupal installation. Drush needs to be installed using composer in each project:

> cd C:\Program Files\Ampps\www\YOURPROJECTFOLDER
> composer require drush/drush

 8. Run "drush status" and confirm it is working. You should have a fully functional Development Environment with Drupal 9.

Make sure you have a good code editor such as Notepad++, Atom, or Visual Studio Code (all free to use).

Method 2: Docksal/Lando

Docksal and Lando are two similar utilities that are more difficult to install but provide a more stable and flexible environment. They operate on top of a virtualized Linux container, powered by Docker. You must have virtualization enabled in the BIOS and WSL activated on your Windows, hence this method is considered more advanced, but once you set it up you have a better environment for working in projects.

1. Install Docker Desktop for Windows:

2. Install Lando or Docksal.

Note: Docksal has an alternative installation method using VirtualBox instead of Docker, which you can read about in the link above.

Note 2: Another popular solution for Windows you can read about and try is DrupalVM: (Advanced)

Evolving Web Newsletter

Sign up for tutorials, best practices and insights, plus info about our acclaimed Drupal Training series.