Note
As of Drupal 10.0, Drush version 11 or later is required. Newer versions of Drush, that is, version 11 and later, must be installed via Composer. Acquia does not manage the update to the newer versions. For more information, see About Drush on Cloud Platform.
If you’re using a multisite installation, following best practices would have you ensure you are in the correct website directory before running a Drush command. However, if you’re using Drush across several applications in succession, using Drush aliases can be more efficient.
You must use aliases when executing Drush commands inside the docroot directory. If you’re not in the specific
multisite directory for which you want to execute Drush commands, you must
also specify the -l
flag and provide a URI. If you use an alias by itself
and you aren’t in the relevant multisite directory, Drush can’t determine which
website it should execute commands for.
For example, if you want to run a pm-list
(or its alias, pml
) and grep
for the sync module on http://www.mysite.org
, use one of the following
commands based on your location:
In the specific multisite installation directory (such as
/var/www/html/mysite.test/sites/mysite.org
)* - No additional Drush
parameters are needed. Use the following command:
drush pml | grep sync
In the website’s docroot, but not the specific multisite directory
(such as /var/www/html/mysite.test
)
You will need the URI for the specific multisite like the following:
drush -l http://domainb.mysite.org pml | grep sync
In the infrastructure’s /var/www/html
directory, but not in the Drupal
installation docroot
You will need both the URI and the Drush alias like the following:
drush @mysite.test -l http://domainb.mysite.org pml | grep sync
You need the alias to specify the Drupal website application since you’re
not in /var/www/html/mysite.test
, and you need the URI since
you’re not in the related multisite directory for
http://domainb.mysite.org
.
If you want to run Drush on all the multisites in an environment that uses
Cloud Hooks, you can use the following command as an example, where
[site]
is the application, and [target.env]
is the environment you
want to run the command in:
drush --root=/var/www/html/[site].[target_env]/docroot @sites updatedb
--yes
Note
The @sites
alias is deprecated in all versions of Drush since Drush 9.