Now that Drupal 8 is in beta phase it is time for site developers to start exploring the API. This article describes the installation and configuration of Drupal 8 using Git and Drush. Bear in mind that as of 2014-11-28 there were 22 issues tagged with D8 upgrade path, so it may be necessary to rebuild your site with the next core update.

Before starting

Clone Drupal 8

$ git clone -b 8.0.x --single-branch http://git.drupal.org/project/drupal.git
$ git remote rename origin upstream
$ git remote add origin [url]
$ git checkout -b master
$ cp example.gitignore .gitignore

Create the files directory and set permissions

$ mkdir sites/default/files

To work efficiently with drush the files in sites/default/files should be writeable both by the web server and command line user. An alternative to chmod -R 777 sites/default/files is to use Access Control Lists.

Those familiar with the Symfony 2 documentation will recognise the following shell commands which have been adapted from the Installing and Configuring Symfony chapter of the The Symfony Book.

$ HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX sites/default/files
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX sites/default/files

HTTPDUSER is usually www-data on Debian-based distributions.

Before setting the access control only the drush user will have rw permissions:

$ getfacl sites/default/files
# file: cache
# owner: drushuser
# group: drushuser
user::rwx
group::rwx
other::rwx

After setting the access control both the web server user and drush user will have rw permissions:

$ getfacl sites/default/files
# file: cache
# owner: drushuser
# group: drushuser
user::rwx
user:www-data:rwx
user:drushuser:rwx
group::rwx
mask::rwx
other::rwx
default:user::rwx
default:user:www-data:rwx
default:user:drushuser:rwx
default:group::rwx
default:mask::rwx
default:other::rwx

Create database

$ mysql -uroot -p
mysql> CREATE DATABASE db;
mysql> CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON db.* TO 'dbuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> \q

Site installation

$ drush site-install standard --db-url=mysql://dbuser:password@localhost/db --site-name=drupal8
$ drush upwd admin --password=password

Drupal 8 beta is now configured and you may login with the username "admin" and password "password".

Configure a Drush alias

$ cp ~/.composer/vendor/drush/drush/examples/example.aliases.drushrc.php ~/.drush/aliases.drushrc.php
$ drush site-alias @self --full --with-optional >> ~/.drush/aliases.drushrc.php

Edit ~/.drush/aliases.drushrc.php and enter your site's URI.

<?php
/**
 * Drupal 8 beta
 */
$aliases["drupal8"] = array (
  'root' => '/var/www/drupal8',
  'uri' => 'http://drupal8',
  '#name' => 'drupal8',
  'path-aliases' => 
  array (
    '%drush' => '/home/seth/.composer/vendor/drush/drush',
    '%site' => 'sites/default/',
  ),
);

Check that your system meets the minimum core requirements:

$ drush @drupal8 core-requirements

Check the status of the site installation by running drush @drupal8 status. The output will be similar to the following:

$ drush @drupal8 status
 Drupal version         :  8.0.0-dev
 Site URI               :  http://drupal8
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :
 Database username      :  drupal8
 Database name          :  drupal8
 Database               :  Connected
 Drupal bootstrap       :  Successful
 Drupal user            :  Anonymous
 Default theme          :  bartik
 Administration theme   :  seven
 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php5/cli/php.ini
 PHP OS                 :  Linux
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /home/user/.drush/aliases.drushrc.php
 Drupal root            :  /var/www/drupal8
 Site path              :  sites/default
 File directory path    :  sites/default/files
 Temporary file         :  /tmp
 directory path
 Active config path     :  sites/default/files/config_jP-uX_4rcMWllW18FM124krsM
                           An44d1rdD2t5zXZLAaQcrXQjUATnoTTQ5gtw-iH5fqcmlTFCQ/ac
                           tive
 Staging config path    :  sites/default/files/config_jP-uX_4rcMWllW18FM124krsM
                           An44d1rdD2t5zXZLAaQcrXQjUATnoTTQ5gtw-iH5fqcmlTFCQ/st
                           aging

Install contrib modules

Two useful modules for developers are devel and examples.

Devel

$ drush @drupal8 pm-download devel
$ drush @drupal8 pm-enable devel

Examples

$ drush @drupal8 pm-download examples
$ drush @drupal8 pm-enable examples

The single command drush @drupal8 pm-enable module will download module (if required) before enabling it.

Regularly update Drupal core

As Drupal 8 pushes on through beta releases you should regularly merge in the latest code:

(master)$ git checkout master
(master)$ git fetch upstream
(master)$ git merge upstream/8.0.x

Remember to rebuild the site after each merge:

$ drush cache-rebuild

Before all issues tagged with "D8 upgrade path" have been closed you may find that you are required to repeat the site installation commands as described above after updating Drupal core.

Further reading