Drush is a command-line shell for Drupal, which you can require as part of your Composer-built Drupal website. With Drush, you can perform administrative and application maintenance tasks from the command line instead of Drupal’s administrative interface.
Acquia recommends you develop your codebase locally, using Composer to build your codebase, and Cloud IDE to sync your code between your local environment and Cloud Platform, rather than attempting to manage code or modules remotely on Cloud Platform.
You can change your application’s code, use Drush locally to install or update modules, and then send the changes to Cloud Platform using version control.
Note
Run Drush commands from your website’s docroot.
Although multiple versions of Drush (Drush 6 to Drush 10) are pre-installed on Cloud Platform, Acquia recommends you require a site-local Drush as part of your codebase, not your home directory, and run your commands with a specific major version of Drush. It is dangerous to run the globally-installed version of Drush because the behavior of your cron jobs, Cloud Hooks, or other automated scripts may change unexpectedly when a new version of Drush becomes the default.
To run Drush commands by typing drush
and not
../vendor/bin/drush
or ../vendor/drush/drush/drush
:
vendor
directory, where the vendor
directory is at the same level as the docroot
directory.vendor/bin
directory that points
to the drush executable located at vendor/drush/drush/drush
.Note
These prerequisites are also applicable for Remote Administration to work with drush.
~/example_repo/vendor/bin$ ls -lha
[email protected] 9 user staff 288B 5 Nov 13:36 .
[email protected] 39 user staff 1.2K 28 Jan 12:17 ..
lrwxr-xr-x 1 user staff 20B 5 Nov 13:36 drush -> ../drush/drush/drush
~/examplerepo$ ls -lha
[email protected] 11 user staff 352B 28 Jan 11:04 .
[email protected] 31 user staff 992B 17 Mar 12:23 ..
[email protected] 1 user staff 3.2K 28 Jan 12:02 composer.json
[email protected] 1 user staff 250K 28 Jan 12:17 composer.lock
[email protected] 21 user staff 672B 28 Jan 12:16 docroot
[email protected] 39 user staff 1.2K 28 Jan 12:17 vendor
~/example_repo/vendor$ ls -lha
[email protected] 39 user staff 1.2K 28 Jan 12:17 .
[email protected] 11 user staff 352B 28 Jan 11:04 ..
[...SNIP...]
[email protected] 3 user staff 96B 5 Nov 13:36 drush
Drush commands not specifying a version of Drush will default to Drush 8.
You can use Drush with your applications after you enable SSH access to connect to Cloud Platform using SSH.
Drush versions and Drupal
To run a specific version of Drush, specify the major version in the drush
command. For example, to run Drush 7, use the command drush7
.
If you want to change your personal default Drush version, you can set an alias
for drush in a .bashrc
file. For example, to make the drush
command run
Drush 7 on interactive bash commands, add the following line to your
~/.bashrc
file:
alias drush=drush7
This alias will have no effect during cron jobs or Cloud Hooks. To use a specific version of Drush in a cron command, you must call it directly, as in the following example:
/usr/local/bin/drush7
When you run Drush on your local machine and use a remote Drush alias for your Cloud Platform application (such as those described in Using Drush aliases), the remote Drush command cannot check for a site-local version of Drush, and will instead run the default version of Drush on Cloud Platform.
Acquia recommends you run Drush commands by specifying the application,
replacing [site]
with your sitename and [env]
with your environment, as in
the following example:
drush --root=/var/www/html/[site].[env]/docroot
To run a specific version of Drush on Cloud Platform when you use a remote
alias, edit the alias file in the $HOME/.drush
folder on your local machine
to specify the version you want. For example:
$aliases['dev'] = array(
'path-aliases' => array(
'%drush-script' => 'drush7',
),
// ... other alias settings here
);
To access help for Drush online, go to Drush Commands.
To view command-line help, enter the command appropriate to your version of Drush on the command line while signed in to your Cloud Platform infrastructure:
drush8 help
drush9 list
for a list of commands, or
drush9 help [command name]
for help for a specific command