Deploying Symfony2 on Dreamhost

There is a few things I had trouble with getting Symfony2 to work on Dreamhost shared hosting. All in all it was quite a mission. So here are some of my steps to help for next time.

We would like to use PHP 5.4. But default the PHP Cli is 5.2. So some changes are required.

Note: Also make sure your domain is set to PHP 5.4 in the Dreamhost Panel.

Step 1:
First we need to enable the custom php.ini, since we also need to add in some extensions for Symfony2. More info here

So to enable PHP 5.4 for all sites, create this folder:
mkdir -p ~/.php/5.4

Step 2:

Then in your .bash_profile in your home folder, add:
export PATH=/usr/local/php54/bin:$PATH
So we are always set with the right version.

Step 3:

Run all the code from the first Gist in your home folder. This will compile the APC extension:

Then open this file and add in the config from the second window above:
vi ~/.php/5.4/phprc

(this enables the required extensions and links the apc module we just made)

Step 4:

From now we we should be set. You can test by running:
$ which php
hopefully it says something like: /usr/local/php54/bin/php

Step 5:

Make sure we have composer:
curl -sS | php

Step 6:

We also need to add in Icu to our require field in composer.json since the Intl Apache module at Dreamhost is a little old. As noted here
"symfony/Icu": "1.1.*"

Step 7:

Next update your project to include that:
php ../composer.phar update --no-dev -o

Step 8:
Perhaps you can do a little dance or something if everything went well. But please celebrate any way you feel appropriate.

6 thoughts on “Deploying Symfony2 on Dreamhost

  1. Step 5 keeps failing for me. It says that Parse error: syntax error, unexpected T_SL in – on line 818. I did a quick look up and some people are saying that means my php version is too low. However I did have dreamhost change it to 5.4 and also did the step with phprc. However when I do $ which php I only get /usr/local/bin/php

    Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *