How to install Drupal 8 (and Composer) on Windows 10 Bash

Kristian Polso • August 8, 2016

Drupal 8 Composer Windows 10 Drupal Planet Lamp

Microsoft released Windows 10 Anniversary Update on August 2nd 2016, and this update included a much awaited "Windows Subsystem for Linux", which allows the user to run bash and command line Linux applications. It uses Ubuntu 14.04 as the base and as such is a great platform for local PHP development. In this tutorial I will show you how to install Drupal 8 (and Composer) environment on it.

Roughly speaking, the necessary steps for this are:

Enable Linux functionality

First, make sure you have the Windows 10 Anniversary Update installed. At the time of this writing, it should be available via Windows Update for all Windows 10 users.

Alright, now you have a Linux shell installed, congratulations! Let's update it to be latest version possible.

 sudo apt-get update sudo apt-get upgrade

Install LAMP

Installing and configuring a LAMP (Linux, Apache, Mysql, PHP) system can take a while, so in this tutorial we are just going go with the defaults to get it running fast.

Install the necessary packages:

 sudo apt-get install apache2 php5 libapache2-mod-php5 mariadb-server php5-mysql php5-cli php5-gd

The installation will ask some configuration (like mysql password), set those to your liking.

Let's start apache and mysql:

 sudo service apache2 start sudo service mysql start

Awesome, now you have a webserver running at http://localhost!

Let's enable clean URLs for Drupal 8:

 sudo a2enmod rewrite sudo service apache2 restart sudo nano /etc/apache2/apache2.conf

Under <Directory /var/www..., change: "AllowOverride None" to "AllowOverride All"

Ctrl+X to save and quit

Restart Apache once more:

 sudo service apache2 restart

Install Mysql database for Drupal 8

Open Mysql command line with command:

 mysql -u root -pYOURMYSQLPASSWORDHERE

And create the database for Drupal 8 by typing:

 CREATE DATABASE drupal8;

Type "quit" to exit Mysql command line

Note that we are using the root user for Mysql, NEVER do this in production! In local, it's fine, but not really recommended.

Install Composer

Installing Composer is pretty straightforward, just go to https://getcomposer.org/download/ and follow the Linux instructions. At the time of this writing the instructions are:

 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"

Let's make Composer global:

 sudo mv composer.phar /usr/local/bin/composer

Alright, now you have Composer available with the command "composer"!

Install Drupal 8

Final step, let's install Drupal 8. Go to the Apache root:

 cd /var/www

Remove the html folder (we will replace that with Drupal 8 installation).

 sudo rm -rf html

Create a new project based on the latest stable version of Drupal 8 with Composer:

 sudo composer create-project drupal/drupal html --stability stable

Set the permission of html folder

 sudo chown -R www-data:www-data /var/www/html

Now surf on to http://localhost and be greeted with your new Drupal 8 installation! Go through the installation procedure as usual. Remember the Mysql username and password you set! The database is drupal8.

 

 

Share This Post