Installing Drush 8

Previously I discussed how to install Drush 6.x for use with Drupal 7. Here we’ll install Drush 8 for Drupal 8, specifically using Ubuntu 16.04 Server.

The recommended method is to install using PHP’s Composer. First we install Composer itself:

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

Then, install unzip to speed things up:

root@ubuntu:/# apt-get install unzip

Installing and Testing Drush 8

Install Drush 8.x:

root@ubuntu:/# /usr/lib/php/20151012/composer.phar global require drush/drush
# Alternatively, of course you can add Composer to your path.

Once Drush has installed, add it to your path, or symlink it, or run it from its binary:

root@ubuntu:/# ln -s /root/.composer/vendor/bin/drush /usr/sbin/drush
root@ubuntu:/# /root/.composer/vendor/bin/drush

Finally, verify that Drush 8 is installed and working:

root@ubuntu:/var/www/html# drush status
 Drupal version                  :  8.1.5
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database port                   :  3306
 Database username               :  geoff
 Database name                   :  geofftest
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  bartik
 Administration theme            :  seven
 PHP executable                  :  /usr/bin/php
 PHP configuration               :  /etc/php/7.0/cli/php.ini
 PHP OS                          :  Linux
 Drush script                    :  /root/.composer/vendor/drush/drush/drush.php
 Drush version                   :  8.1.2
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :
 Install profile                 :  minimal
 Drupal root                     :  /var/www/html
 Drupal Settings File            :  sites/default/settings.php
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp
 Sync config path                :  sites/default/files/config_ZL-bcxvDlSAuux6UyP4tEouFcoQFhvTaBoNtczFto_
                                    E23JpzSdFp3Ie0cbwlNGSzCXQQbhltWw/sync

Finally, if desired, put your drushrc.php file where Drush can see it.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *