Configuring Drush site aliases for Drupal
Drush site aliases allow you to run Drush commands on remote Drupal sites directly from your local computer. This makes it easier to manage multiple sites, automate updates, and streamline administration. On ruachost.com, you can configure site aliases to securely connect to your hosted Drupal installations.
Why Use Site Aliases?
Section titled “Why Use Site Aliases?”- Run Drush commands locally that execute on remote servers.
- Automate updates across multiple Drupal sites.
- Simplify workflows by avoiding repeated SSH logins.
- Improve efficiency for developers and administrators.
Steps to Configure Drush Site Aliases
Section titled “Steps to Configure Drush Site Aliases”Step 1: Create Alias File
Section titled “Step 1: Create Alias File”-
On your local computer, navigate to your home directory:
- Linux →
/home/username - macOS →
/Users/username - Windows →
\Users\username
- Linux →
-
Open the
.drushsubdirectory (create it if it doesn’t exist). -
Create a file named:
sitename.aliases.drushrc.php(Replace
sitenamewith a descriptive name for your site.)
Step 2: Add Configuration
Section titled “Step 2: Add Configuration”Paste the following sample configuration into the file, replacing values with your own:
<?php$aliases['sitename'] = array( 'root' => '/home/username/public_html', 'remote-host' => 'example.com', 'remote-user' => 'username', 'ssh-options' => '-p 7822',);?>- root → Path to your Drupal installation.
- remote-host → Your site’s domain name.
- remote-user → Your hosting account username.
- ssh-options → Port number (Ruachost uses port 7822 by default).
Step 3: Set Up SSH Keys
Section titled “Step 3: Set Up SSH Keys”- Drush does not allow storing SSH passwords in alias files.
- To avoid typing your password every time, configure SSH keys for your Ruachost account.
- See Ruachost documentation on setting up SSH keys.
Step 4: Use the Alias
Section titled “Step 4: Use the Alias”Run Drush commands by prefixing with @sitename. Examples:
drush @sitename statusdrush @sitename upstatus→ Displays site information.up→ Updates the site.- Any Drush command can be run using the alias.
Important Notes
Section titled “Important Notes”- Always back up your site before running update commands.
- Use descriptive alias names if managing multiple sites.
- If your hosting account uses a different SSH port, update the
ssh-optionssetting.