Setting up a Drush alias

When you need to setup an alias for running your drush commands. For instance you need to do something like:

drush @mysite.local cr

drush @mysite.staging cr

And so and so far and target different environments more easily. 

It's fairly simple. 

One of the first things you need to do is find where your drush is installed. One ways I do to find out is to go to your Drupal root and run the command drush status. One of the outputs will tell you the drush path.

Once you go there you want to local drush.yml and assign an alias-path. Like this:

drush:
  paths:
    alias-path:
      - '/custom/path//sites'

Obviously you'll want to change /custom/path to someplace that exists. Go to that path and create a new YML file. The format of the filename should be alias_name.site.yml

 local:
   host: test.domain.com
   user: www-admin
   root: /other/path/to/drupal
   uri: http://test.com
   paths:
     drush-script: '/path/to/drush'

Then once you're done you can do something like: drush @alias_name.local status

And hopefully that will work

Blog tags