Installing Composer on Dreamhost

How to enable Phar and install Composer on Dreamhost.

This should work with PHP 5.4 as well, just swap out instances of 5.3 with 5.4 ๐Ÿ™‚

Make PHP 5.3 default

At Dreamhost there are two php binaries. ‘php’, which is version 5.2, and ‘php-5.3’ which is 5.3. We need to use 5.3 and Phar/Composer gets confused if the version of the ‘php’ command isn’t actually version 5.3.

$ mkdir -p ~/bin
$ ln -s /usr/local/bin/php-5.3 ~/bin/php
$ echo "export PATH=~/bin/:\$PATH" >> ~/.bash_profile
$ echo "export PATH=~/bin/:\$PATH" >> ~/.bashrc

Here we make our own little bin directory and creates a symlink to ‘php-5.3’ called ‘php’. We then add this directory to the beginning of the path so this directory is searched first when you try to run ‘php’. So if you log in and out of the shell (to reload the .bash_profile), you should get 5.3 if you run php --version.

Enable Phar

$ mkdir -p ~/.php/5.3
$ echo "extension =" >> ~/.php/5.3/phprc
$ echo "suhosin.executor.include.whitelist = phar" >> ~/.php/5.3/phprc
$ php -m | grep Phar

Last step should output “Phar”, if it all worked. If not, try the php.ini-way instead in this guide (which is where I found how to do this in the first place, but found it a bit unclear. Especially the last suhosin stuff).

Install Composer

$ curl -s | php -- --install-dir=~/bin
$ chmod u+x ~/bin/composer.phar
$ composer.phar

That last step should then give you a bunch of info and no error messages. And Composer should be ready to go ๐Ÿ™‚

  • Great, super handy, tx!

  • Rafael Ortega Bueno


  • Is this still valid for php 5.4 on Dreamhost ?

    • Didn’t know they had made 5.4 available, but I assume so? Maybe switch to using PHP 5.4 instead though. Let me know how it works out ๐Ÿ™‚

    • Yes it works with php5.4

  • Lango

    Worked great. The only thing I had to change was in the last step with teh curl command, I couldn’t use ..install-dir=~/bin, I had to use the full directory. So …install-dir=/home/username/bin

    • or else use –install-dir=$HOME/bin which worked for me.

  • Ziiweb

    I had to reboot the system to get the new version of php, after “php -v”.

    • Reboot? Should just be a path issue which might require relogging the shell. But good to hear you managed to get it to work anyways ๐Ÿ™‚

  • ziiweb

    Thanks, insteof of “php — –install-dir=~/bin” I had to write “php — –install-dir=/home/me/bin”

  • Adam

    Great, thanks!

  • Nico

    Thanks much!

  • kminek

    based on your info i put together small shell script to automate the process: ๐Ÿ™‚

    • Jared Taylor

      kminek, will this also work on a VPS?

  • Andrew

    Worked great, but I too had to use the full path to my bin folder…composer returned this when I used the relative path:

    #!/usr/bin/env php
    All settings correct for using Composer
    The defined install dir (~/bin) does not exist.

  • John Horner

    No need to log out of the shell and log in again to reload your .bash_profile, just do “source .bash_profile” and it reloads.

    • That would work too. I should probably start doing that. Relogging just feels more… definite :p

  • glitchdata

    Worked beautifully. And for those of you looking to get Zend Framework 2 going, its a simple update.

    • Jared Taylor

      Hey guys, trying to follow the instructions above, but not getting Phar to enable. A little help, please?

  • Thank you for this!

  • Assunรงรฃo Jr

    Big thank’s

  • Pingback: Installing Laravel 5 on Dreamhost VPS – Don't Make Me Think()