Installing Composer on Dreamhost

Published:

How to enable Phar and install Composer on Dreamhost.

Update 2013-04-22: 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 = phar.so" >> ~/.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 https://getcomposer.org/installer | 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 🙂