Installing Drush on a Shared DreamHost Account

[box type=”note”]If you have issues with these directions, please read the alternate directions for installing on a shared host manually without using Pear. MediaTemple is one provider where you must use the alternate directions to get Drush working.[/box]

One of the easiest and most convenient ways to get your hands on Drupal is on a shared hosting environment. It’s pretty much where everyone is going to start from unless you happen to have a giant long-term budget for your own hardware.

You have a number of options when it comes to hosting and at one time or another I’ve tried a lot of them. Three companies that have managed to keep me the happiest though are A Small Orange (use coupon 15-off to get 15% off; no affiliate), DreamHost (no affiliate) and MediaTemple. I’ve found DreamHost in particular to be pretty impressive when it comes to hosting a lot of one-off sites on my very inexpensive shared plan. I even use it when rapid prototyping for clients.

The best part though is that with DreamHost I can use SSH and Drush the way I normally would like to on a dedicated or virtual server. Set up is a bit more complex than normal, but, once it’s set up for your user it’s smooth sailing.

Before you can do any of this, you will need to make sure you enable SSH for the user you assigned to the  domain you want to use Drush with. You can find these options under the Manage Users section of the DreamHost panel. From there open up your favorite SSH client and log into your site (PuTTY works well on Windows, you can just run ssh from the command line on Mac or Linux).

Since you’re in a locked-down shared hosting environment, you obviously can’t make system-wide changes. The easiest way to install Drush is though Pear. Pear, by default, wants to make system-wide changes. Since we can’t do that in a shared environment, our first order of business will be to set up a new instance of pear just for our user.

Once logged in, and in your user’s home folder, run:
pear config-create ${HOME} ${HOME}/.pearrc
pear install -o PEAR

Now you have your own instance of pear, but you still can’t use it yet. To fix this, we will edit our .bash_profile and add in the path to the most recent PHP version DreamHost provides, as well as adding in our pear directory early on in this user’s PATH.

Open ~/.bash_profile in your favorite editor:
nano ~/.bash_profile

And add these lines at the bottom of the file:
export PHP_PEAR_PHP_BIN=/usr/local/php53/bin/php
export PATH=${HOME}/pear:/usr/local/php53/bin:${PATH}

Finally, re-load the file so the changes will take effect immediately:
. ~/.bash_profile

Now we have the newest version of PHP and our custom version of pear available to us, to check this out, you can run these commands:
which php
which pear

Pretty cool, eh? Lastly, just run the usual install command for drush to install it:
pear channel-discover
pear install drush/drush

Now you can use drush from any site under this user as you would anywhere else (try running `drush help` for some cool examples). You can repeat this process for any other SSH users on your account. A one line tl;dr version of this process is included below for your automated and repetitive pleasure. Enjoy!

tl;dr: Get drush running on DreamHost by running this line in SSH:
pear config-create ${HOME} ${HOME}/.pearrc;pear install -o PEAR;echo "export PHP_PEAR_PHP_BIN=/usr/local/php53/bin/php" >> ~/.bash_profile;echo 'export PATH=${HOME}/pear:/usr/local/php53/bin:${PATH}' >> ~/.bash_profile;. ~/.bash_profile;pear channel-discover;pear install drush/drush

[box type=”note”]

Robin Monks has a passion for openness and freedom in technology and he’s spent the last 8 years of his life developing, supporting and maintaining open source software. He’s part of the panel of Drupal community experts who authored The Definitive Guide to Drupal 7 and currently provides independent consulting services. Reach him at 1-855-PODHURL.[/box]

Show CommentsClose Comments


  • Dale
    Posted February 26, 2012 at 9:39 pm 0Likes

    Thanks for this, Robin!

    Have you tried doing Drush remote commands using aliases? (ref When I did, I discovered the path exports needed to be in .bashrc so they were available to remote commands. I moved them .bashrc and do a “source ~/.bashrc” in .bash_profile.

    It is so sweet doing a drush @remotesystem status on my laptop and seeing results from my Dreamhost site.

  • dalin
    Posted February 27, 2012 at 6:56 pm 0Likes

    Wouldn’t it just be easier to do a git checkout of drush?

  • Dale
    Posted March 1, 2012 at 4:57 am 0Likes

    I’ve done from a tarball (essentially the same as GIT) and I’ve done it with PEAR. PEAR is much more convenient. YMMV.

  • Bryce Benton
    Posted September 8, 2012 at 3:39 pm 0Likes

    This worked exactly as described. Thanks!

  • VF
    Posted November 13, 2012 at 12:25 am 0Likes


    I did exactly that. Trying a Drush command I get error:

    Could not open input file: /home/username/pear/drush.php

    • Robin Monks
      Posted December 6, 2012 at 4:39 pm 0Likes

      I’m hoping you replaced username with your username?

  • David
    Posted November 27, 2012 at 8:24 pm 0Likes

    I’m getting PHP Warnings when it tries to load modules. Here are just a few of the warnings:

    PHP Warning: Module ‘bcmath’ already loaded in Unknown on line 0
    PHP Warning: Module ‘bz2’ already loaded in Unknown on line 0
    PHP Warning: Module ‘calendar’ already loaded in Unknown on line 0
    PHP Warning: Module ‘ctype’ already loaded in Unknown on line 0
    PHP Warning: Module ‘curl’ already loaded in Unknown on line 0

    Doing a php -i on the command line gives me some info on the config. Looks like two php.ini files are being loaded that both specify the same extensions.

    Configuration File (php.ini) Path => /etc/php53
    Loaded Configuration File => /etc/php53/php.ini
    Scan this dir for additional .ini files => /etc/php53/conf.d
    Additional .ini files parsed => /etc/php53/conf.d/php.ini

    Some of the extensions:

    extension =
    extension =
    extension =
    extension =
    extension =

    Anybody know how to get dreamhost not to load two php.ini files?

    • Robin Monks
      Posted December 6, 2012 at 4:39 pm 0Likes

      One option would be to tone down the error reporting to not show warnings. Warnings won’t actually harm anything.

  • Paul Wieck
    Posted December 31, 2012 at 7:36 pm 0Likes

    Thank you for your how-to. Worked perfectly.

  • Ian C
    Posted February 3, 2013 at 4:07 am 0Likes

    worked exactly as described. thank you for posting.

  • Eric Powell
    Posted April 14, 2013 at 9:17 pm 0Likes

    Thank you for the instructions. This made it simple and worked perfectly.

  • Dhruv
    Posted April 24, 2013 at 11:49 am 0Likes

    Nice, clear and the shortest instruction on installing drush at DreamHost. Now that php version 5.4 is available, you might want to change php53 to php54.

    Although php53 works just fine but I think it’s better to have the latest php version. What you think?

    Thanks for offering such a simple solution.

    • Robin Monks
      Posted April 24, 2013 at 11:55 am 0Likes

      You can (and should) if php54 exists on the shared server you’re hosted on. I haven’t switched the directions to 5.4 entirely because I don’t believe DreamHost has rolled it out everywhere yet.

  • Dhruv
    Posted April 25, 2013 at 3:49 am 0Likes

    I have checked with DreamHost support staff and they have confirmed that php54 is available on all DreamHost servers. It’s also just announced in the latest DreamHost newsletter v15.3&4.

  • Shankar
    Posted May 9, 2013 at 5:13 am 0Likes

    You can check Drush version with “drush status” command inside your application directory or outside your application directory, the difference will be when you are inside application directory you will get more information,

    Check below links for better understanding on Drush commands,

    • Robin Monks
      Posted May 16, 2013 at 12:15 pm 0Likes

      Just a warning that the upgrade instructions in your second link won’t work for anyone using the installation method here on a shared host. If you use the direction here you must update via pear. To update, just run:

      pear upgrade drush/drush

  • Daniel
    Posted June 4, 2013 at 4:07 pm 0Likes

    I just wanted to say thanks for this. It worked great.

  • Pixeldroid
    Posted November 21, 2013 at 3:44 pm 0Likes

    Hi there! Found this page while looking for instructions on installing Drush on Dreamhost. I have followed all the steps, but drush still wouldn’t initiate until I added those 2 lines:

    export PHP_PEAR_PHP_BIN=/usr/local/php53/bin/php
    export PATH=${HOME}/pear:/usr/local/php53/bin:${PATH}

    to my .bashrc file. Everything is working fine now. Thank you for your detailed instructions!

  • Brandon M
    Posted November 30, 2013 at 7:41 am 0Likes

    The most recent version of drush was not allowing me to install using the /usr/local/php53 directory and when I updated the bash_profile to use the php54 directory it was not working either. I would get the error “Your command line PHP installation is too old. Drush requires at least PHP 5.3.3.” this is because the /usr/local/php53 version is actually PHP 5.3.27 (cli)…

    So to fix it I uninstalled drush using..
    pear uninstall drush/drush

    Then I edited the bash_profile to reflect php 5.4 instead of php53
    export PHP_PEAR_PHP_BIN=/usr/local/php54/bin/php
    export PATH=${HOME}/pear:/usr/local/php54/bin:${PATH}

    Then I reinstalled with
    pear install drush/drush

    Thank you for the tutorial and I hope this helps anyone who gets stuck.

  • kaglugub
    Posted August 9, 2014 at 7:27 pm 0Likes

    This worked great. Thank you!

  • DreamDrush
    Posted September 26, 2014 at 4:29 pm 0Likes

    When creating/editing a user on DreamHost, you get the following options..

    User Type:

    FTP user – allows login via FTP for file transfers only.
    SFTP user – allows login via SFTP (SSH file transfer) for file transfers only.
    Shell user – allows login via SSH (secure shell) for command-line access, as well as SFTP.
    Shell Type: (dropdown menu)
    Disallow FTP? (checkbox option)

    Any suggestions on which shell type to use?

  • Ralph Manis
    Posted September 5, 2015 at 9:14 am 0Likes

    FYI Your “note” box code is not working correctly and showing up on your pages.

    [box type=”note”] [/box]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Our time: 11:40am PDT