How to Install Drush on CentOS 8
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Drush is a command line tool for creating, administrating, and modifying Drupal websites. Command line tools, like Drush, add functionality through additional command packages. Once installed, Drush is as easy to use as any of the basic Linux commands. The name comes from combining the words Drupal and shell. Drush is designed only for Drupal and cannot be used with other content management systems.
Both new and experienced Drupal users can benefit from learning Drush. Users that have worked with a command line interface before have an advantage, but Drush is an excellent application for beginners, too.
Before You Begin
Before installing Drush, ensure that you complete the following steps:
If you have not already done so, create a Linode account and Compute Instance. See our Getting Started with Linode and Creating a Compute Instance guides.
Follow our Setting Up and Securing a Compute Instance guide to update your system. You may also wish to set the timezone, configure your hostname, create a limited user account, and harden SSH access.
Install and configure a LAMP stack on CentOS 8.
NoteThis guide is written for a non-root user. Commands that require elevated privileges are prefixed withsudo
. If you’re not familiar with thesudo
command, you can check our Users and Groups guide.
Install Git & Composer
The developers of Drush recommend installing Drush using Composer, a PHP dependency manager. Since the Drush project is hosted on GitHub and controlled with Git, you will also need to install Git. In this section, you will install both dependencies.
Install Git:
sudo yum install git
Composer requires several PHP extensions in order to work properly. Install these extensions on your system:
sudo yum install php-json, php-zip, unzip, php-mbstring, php-gd -y
Install Composer:
curl -sS https://getcomposer.org/installer | php
Move the
composer.phar
file to/usr/local/bin/
, so that it can be accessed from any directory:sudo mv composer.phar /usr/local/bin/composer
Install Drush Globally
Composer is designed to install PHP dependencies on a per-project basis. The steps below will install a global Drush for all projects. If you want to install Drush for a specific system user, skip to the Install Drush for a Limited User Account section.
Create a symbolic link between Composer’s local bin directory,
/usr/local/bin/composer
, and the system’s bin directory,/usr/bin/
:sudo ln -s /usr/local/bin/composer /usr/bin/composer
Use Git to download - or clone - the GitHub Drush project into a new directory,
/usr/local/src/drush
:sudo git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
Change the working directory to your new Drush directory:
cd /usr/local/src/drush
Use Git to checkout the version of Drush that you wish to use. View the GitHub project’s releases page to view all available versions.
For a different release, replace the version number,
10.2.2
, in the following command:sudo git checkout 10.2.2
Create a symbolic link between the Drush directory in
/usr/local/src
to/usr/bin
, so that the Drush command can be called from any directory:sudo ln -s /usr/local/src/drush/drush /usr/bin/drush
Now, run the Composer install command:
composer install
Drush has now been installed for all users on your Linode. To verify the installation, check Drush’s version number.
drush --version
You should see a similar output:
Drush Commandline Tool 10.2.2
Install Drush for a Limited User Account
You may want to install Drush for only certain system users, for example, the site admin or the Apache webserver. This option may be optimal for a shared-hosting environment. Also, this allows individual users to install different versions of Drush and even install separate versions specific to a single project. Ensure you run the commands from the limited user account’s home directory. Before you complete this section, ensure you have completed the steps in the Install Git & Composer section of the guide.
Install Drush using Composer:
composer require drush/drush:dev-master
Note
To install a different version of Drush, replacedrush/drush:dev-master
with another version. For example, to install the stable release of Drush 6.x, usedrush/drush:9.*
. For more information, visit the Drush GitHub repository.To verify the installation, check Drush’s version number.
drush --version
You should see a similar output:
Drush Commandline Tool 10.2.2
Note
If your system is having trouble finding the
drush
command, add thevendor
directory to your$PATH
. Using the text editor of your choice, edit your.bashrc
file to add the directory to it’s path:- File: ~/.bashrc
1
export PATH="$HOME/vendor/bin:$PATH"
Run the
source
command on the.bashrc
file to enable the changes:source ~/.bashrc
Using Drush
Drush has dozens of commands with hundreds of options. Drush can interface with MySQL, Drupal, Git, and more. Below are a few examples of some useful Drush commands to get you started. Refer to the Drush Commands documentation for more details.
To get started with Drush, run it without any sub-commands to list the help manual.
drush
View more detailed documentation for a specific command by typing
drush help
and then the command, for example:drush help site-install
Use the
status
command to list several of the specs for your Linode and Drupal website:drush status
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on