To Install Drupal 8 With Drush 8

Drush runs on Drupal 6, 7 and 8 However, Drupal 8, works with only Drush 8.

In order to proceed, its assumed you have already installed Drush 8 with your system/server.  If not yet done so, please check Drush in Drupal.

  1. Before starting anything else, make sure your server has mod_rewrite enabled.  Drupal 8 needs this as, by default CLEAN URLS are enabled and used in Drupal 8, for which mod_rewrite is needed.
    So, with your server / setup check if mod_rewrite is available in Apache2 by firing a command :

    apache2ctl -M

    If it doesn't list the module make sure you install it and enable as well by giving command :

    sudo a2enmod rewrite

    It will enable the rewrite module for your server. Restart apache with :

    sudo systemctl restart apache2

    for changes to take effect. Just to ensure if its done, give command :

    apache2ctl -M

    to see if rewrite module is enabled.

  2. Now that you have rewrite module enabled, next step is to make needed changes in Apache Configuration file.  If you are unsure where exactly it is located, you can find the one using :

    find /etc -name apache2*

    It should be usually located in "/etc/httpd/conf", "/etc/apache2", "/etc/apache2/apache2.conf".  Now, edit the apache configuration file as :

    sudo nano /etc/apache2/apache2.conf

    And change entry :

    <Directory "/var/www/html”>AllowOverride None</Directory>

    To

    <Directory "/var/www/html”>AllowOverride All</Directory>

    Make sure to add one if its not already present.  Don't forget to restart the apache server :

    sudo systemctl restart apache2

    Once, above two steps are taken care of, we are good to move ahead for Drupal 8 Installation.

  3. To download the latest Drupal 8 Branch using drush Make sure, you are moved into the document root of your system, i.e. "/var/www/html" in case of ubuntu 16.04 in discussion. Now fire the below command :

    drush dl drupal-8 --select

    The last argument i.e. "--select" is provided in order to choose which version should be downloaded. Ideally, it should be "Security, Supported, Recommended" version. But of-course, choice is always yours.

  4. Once you choose and download the needed version, we will get detailed information about the chose profile and available modules. Make sure, every details are correct and as per requirements.
  5. Now, that we have downloaded the drupal core, we will move ahead to create the needed database for the site.
  6. Use below command to login to mysql and create database.

    mysql -u root -p
    create database <database_name>

  7. Now that, our database is created, its time to install the site. Switch into the downloaded drupal folder i.e. in this case drupal-8.5.2. Once you are in the drupal folder, Use command :

    drush si standard --db-url=mysql://[db_user]:[db_pass]@[ip-address]/[db_name]

    You can always pass the parameters to this install such as site-name or account-name etc. For this and other detailed commands, please refer my another post on all commands collected at one place here.

  8. Upon installation completion, drush on terminal will provide you the final result and login credentials for the admin user including password. You are strongly suggested to change the password, the moment you login as super admin in your drupal site if not set through above command already.
  9. Now that, we have completed the remaining process for installation, its time we do some tightning of drupal files for security reasons. Considering you are still in drupal setup root folder :

    chmod 755 sites/default/settings.php
    chmod 777 sites/default/files

  10. Finally, for Protecting site against HTTP HOST Header attacks (prevent your site from thinking it is someone else), enable the trusted host mechanism. To do this, edit settings file of drupal :

    sudo nano sites/default/settings.php

    and add :

    $settings['trusted_host_patterns'] = array(
         '^localhost$’,
         '^184\.88\.236\.173$’,
         '^127\.0\.0\.1$’,
    );

    under trusted host patterns. Just for demo, I have given local address, but you can give it as and what it needed.

That's it ! Your are ready to browse and use installed version 8 of Drupal.

Add new comment