I've got a new business name and a new website. Go to www.smilodoncreative.com to learn all about it! 


How to install Drush on a Dreamhost shared server

Okay, y’all. A bit of a nerdtown departure from the usual. 

I was recently trying to install drush on a shared DreamHost server, which I know is 100% possible because I’ve done it. But I could not remember how I did it and I had to stitch together like 13 different instructions and it made me literally curl up in a ball on my bed.

So, here is my personal guide to installing drush on a shared DreamHost server.  (Updated 11/20/15 for PHP 5.6)

(tl;dr version here)

Steps:

  1. From your home directory, install composer:

    [home]$ curl -sS https://getcomposer.org/installer | php
     
  2. Get this error message:

    #!/usr/bin/env php
    Some settings on your machine make Composer unable to work properly.
    Make sure that you fix the issues listed below and run this script again:

    The phar extension is missing.
    Install it or recompile php without --disable-phar

     
  3. Add phar. Other people will tell you to uncomment this in your php.ini file, but on DreamHost shared servers, you can’t get in there. It’s a secret saved only for others.  So you need to create a new one that you CAN get to.

    [home]$ mkdir -p ~/.php/5.6
    [home]$ nano ~/.php/5.6/phprc

     
  4. Add this to the file you just created:

    extension = phar.so
    suhosin.executor.include.whitelist = phar


    Then save and quit (if using nano, Cntl+O, enter, Cntl+X)
     
  5. Add all these things to your ~/.bash_profile (it's in your home directory)

    export PATH=/usr/local/php56/bin:$PATH
    alias composer='php /home/myusername/bin/composer.phar'

     
  6. Try this:

    [home]$ curl -s https://getcomposer.org/installer | php
    #!/usr/bin/env php
    All settings correct for using Composer
    Downloading...

    Composer successfully installed to: /home/yoursite/composer.phar
    Use it: php composer.phar


    YAY!
     
  7. But when you try to do your thing:

    [home]$ composer global require drush/drush:6.*
    -bash: composer: command not found


    Goddammit.
     
  8. Follow the ancient wisdom of doing what the command line says. If the command line says, “Use it: php composer.phar”, use it.

    [home]$ php composer.phar global require drush/drush:6.*
    Changed current directory to /home/yoursite/.composer
    ./composer.json has been created
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
     - Installing drush/drush (6.6.0)
    Downloading: 100%
    Writing lock file
    Generating autoload files
  9. Try it:

    [home]$ drush
    -bash: drush: command not found


    FML.com

  10. Add this shit to .bash_profile

    export PATH="$PATH:~/.composer/vendor/bin"

  11. You may need to logout and log back in because the server likes the sound of doors opening and closing.

  12. NOW run drush. You should get a big long list of drush commands that I will not paste here to save both our eyeballs.

Probably what I have done here is ugly and a sin against our unix forebears. But you know what?

Hope this helps somebody out. I know I’ll be using it next time I gotta do this ish.  No results guaranteed, your mileage may vary, works on my machine, etc.

EDITED TO ADD:  Here's a shorter version of the above instructions, no snarky commentary or errors demo'd.  

Steps:

  1. Add phar

    [home]$ mkdir -p ~/.php/5.6

    [home]$ nano ~/.php/5.6/phprc

  2. Add this to the file you just created:

    extension = phar.so
    suhosin.executor.include.whitelist = phar


    Then save and quit (if using nano, Cntl+O, enter, Cntl+X)
     
  3. Add all these things to your ~/.bash_profile (it's in your home directory)

    export PATH=/usr/local/php54/bin:$PATH
    alias composer='php /home/myusername/bin/composer.phar'

     
  4. Try this:

    [home]$ curl -s https://getcomposer.org/installer | php

    You'll get this if it goes well: 
    #!/usr/bin/env php
    All settings correct for using Composer
    Downloading...

    Composer successfully installed to: /home/yoursite/composer.phar
    Use it: php composer.phar


    YAY!
     
  5. Then do this:
    [home]$ php composer.phar global require drush/drush:6.*
  6. Add this to .bash_profile

    export PATH="$PATH:~/.composer/vendor/bin"

  7. Logout and log back in.

  8. NOW run drush. Ta-da!

Tags: