The radical changes that Drupal 8 brought forward have been reflected in Drush 7 as well. Drush 7 now uses composer to download its dependencies. Before installing Drupal 8 you must make sure that Drush 7 has been installed. This is because Drupal 8 can be downloaded and installed using Drush like in the previous versions of Drush and also, Drupal 8 only supports Drush 7. Unlike earlier versions, Drush 7 cannot be installed using "sudo apt-get install drush" nor can it be updated by running "drush self-update" because that will result in updating to Drush 6 and no more. Hence the purpose of this article.
Drush is a powerful tool to manage routine tasks in a Drupal site. Downloading, installing or enabling modules, running cron and much more can be accomplished using Drush. This is why its important to have Drush 7 before a Drupal 8 installation. Drupal 8 requires minimum version of PHP 5.4. Apache requirements haven't been mentioned, but I recommend apache2.4. After this we can begin installing Drush 7.
As I have mentioned earlier, Drush uses composer to install its dependencies, so first we have to install composer. Install composer globally on your system or server because with Drupal 8 composer will be required quite often.
- To download composer, you will have to run the command "curl -sS https://getcomposer.org/installer | php". Make sure you have permissions. Run this command from the home folder. If curl is not installed in your system, run "sudo apt-get install curl". curl is a tool to transfer data from or to a server, using one of the supported protocols. Run "man curl" for more details.
- After it has been downloaded, run "sudo mv composer.phar /usr/local/bin/composer". Now you can run "composer --version" to see if its working.
- Remove any earlier versions of Drush if installed, otherwise it will cause conflicts.
- Run "composer global require drush/drush:dev-master" from the home folder. Make sure you have permissions or run with sudo. This will give you the latest version of Drush.
- If all goes well you will see an output like this :
Changed current directory to /home/user/.composer ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) - Installing pear/console_table (1.1.5) Downloading: 100% - Installing symfony/yaml (v2.2.1) Downloading: 100% - Installing d11wtq/boris (v1.0.8) Downloading: 100% - Installing drush/drush (dev-master 6ce7202) Cloning 6ce72029d154abe9cf8d0a7c8d7ebf44d511294a pear/console_table suggests installing pear/Console_Color (>=0.0.4) drush/drush suggests installing youngj/httpserver (dev-master#41dd2b7 as 1.0.1)
- This will install in the directory: ~/.composer/vendor/drush/drush, so we will have to set path.
- ln -s /home/<linux user name>/.composer/vendor/drush/drush /usr/bin/drush
- export PATH="$PATH:/home/<linux user name>/.composer/vendor/drush/drush:/usr/local/bin"
- Run "drush status" to see if drush has been installed.
- We have to edit the .bashrc file and include the export statement in it, otherwise the PATH variable set will not be reflected in every bash terminal instance.
- Run "gedit .bashrc" on terminal at the home folder. If .bashrc does not already exist, you can create one now.
- At the beginning of the document, include the line " export PATH="$PATH:/home/<linux user name>/.composer/vendor/drush/drush:/usr/local/bin" ", save the file and exit.
- The .bashrc file will be executed every time the terminal or any bash console is run. This will set the PATH variable every time bash runs.
- Open a new terminal and run "drush status" to see whether this has worked.
If running "drush status" gives an error "drush is not installed. Run sudo apt-get install drush", then either Drush installation did not go as planned or the PATH variable was not set properly.
- Run "echo $PATH" and check whether Drush path is there in your PATH variable.
- This is how a normal PATH variable looks in an ubuntu system :
- Make sure you did not change anything else in the .bashrc file and that you have write permissions.
- Go to the Drush installation folder: .composer/vendor/drush/drush and check whether Drush has been downloaded there. This can happen if, either you did not have the required permissions or if there was a problem with connection on either end and the request timed out.
- In that case run "composer global require drush/drush:dev-master" again or navigate to .composer/ folder from terminal and run "composer update drush"
- To update composer, navigate to .composer/ and run "composer update". This will also update drush/drush:dev-master.
Drush is important and essential to work alongside with Drupal.With composer, a powerful dependency manager, it is easier to download and install Drush. Once set up, Drush 7 and Drupal 8 is something that gets any web developer excited!