Installing symfony on Dreamhost using PEAR

I tried to get all of the commands put down in this how-to, so that people of all skill levels could follow the instructions. Be sure to let me know if I missed any or something needs clarified. :) But as usual, use at your own risk, yadda, yadda.

Conventions used in this how-to (replace with the appropriate values for your account as needed):

  • username: your main account username viagra senza ricetta
  • projects_directory: the directory in which you've gathered the non-web files of all your projects. I'm working on the assumption that this directory is outside the web-accessible domain directories (e.g. /home/username/projects_directory).
  • project_name: the name of a project for which you've created a subdirectory (/home/username/projects_directory/project_name).
  • example.com: domain or subdomain where you wish to have the symfony project be accessed (located /home/username/example.com and viewed on the web at http://example.com).
  • $ is the just a placeholder for the shell prompt. (You'll actually see something like [server_name]$, which is just showing which server your account is on.) This is just a visual cue that you're typing the commands that follow it in at the shell prompt.
  • text in this font is meant to be typed in by you (when preceded by the shell prompt: $) or is explaining directory structure (e.g. /home/username).
  • This site has a good list of linux commands, if you're not familiar with them. The ones you'll need the most for this are cd, pwd, mkdir, ln and rm.

Ok, on with the instructions. :)

  1. Install a custom pear installation on your account (instructions adapted from here).
    1. Log in to your shell account and issue the following commands in your home directory (/home/username):
      1. $ pear config-create $HOME .pearrc
      2. $ pear config-set download_dir /home/username/tmp/pear/cache
      3. $ pear config-set cache_dir /home/username/tmp/pear/cache
      4. $ pear config-set temp_dir /home/username/tmp/pear/temp
      5. $ pear install -o PEAR
      6. $ export PHP_PEAR_PHP_BIN=/usr/local/php5/bin/php
      7. $ export PATH=/home/username/pear:/usr/local/php5/bin:$PATH
        (N.B. You'll need to repeat commands 6 and 7 each time you log in to shell if you plan on using the command line interface. If you want to have the changes be made automatically when you log in, you'll need to add those two lines to your .bash_profile in your home directory.)
    2. Check to make sure everything worked:
      1. $ which php should answer /usr/local/php5/bin/php.
      2. $ php -v should answer that the version is >= 5.0. (Necessary because symfony is written for PHP ver. 5+)
      3. $ which pear should answer /home/username/pear/pear.
      4. $ pear -V should answer that the version is >= 1.4.0. (Which is necessary because of the use of channels to install symfony from the project's server.)
  2. Install symfony (instructions summarized from here):
    1. Tell pear to find the symfony project's channel: $ pear channel-discover pear.symfony-project.com
    2. List the projects available for download from this channel (symfony should be listed in the results): $ pear remote-list -c symfony
    3. Tell pear to install symfony from the symfony channel: $ pear install symfony/symfony
    4. Check what version of symfony is now installed: $ symfony -V should answer something like symfony version 1.0.5.
  3. Create a directory to store your projects in, above the web accessible domain directories (/home/username/projects_directory): $ mkdir projects_directory
  4. Create your project and application(s). In the projects_directory:
    1. Create a directory for your project: $ mkdir project_name
    2. Change directories to the one you just created: $ cd project_name
    3. Tell symfony to create the project: $ symfony init-project project_name
    4. When you list the directory ($ ls -la), you should see a directory structure something like this:

      apps/
      batch/
      cache/
      config/
      data/
      doc/
      lib/
      log/
      plugins/
      test/
      web/

    5. Create the application: $ symfony init-app app_name. That creates a app_name/ directory in the apps/ folder of the project root.
  5. Create symbolic links (adapted from here):
    1. This link tells the server where the symfony images, CSS files, etc., are for the administration pages (type this all on one line): ln -s /home/username/pear/data/symfony/web/sf /home/username/projects_directory/project_name/web/sf
    2. This creates a symbolic link (symlink) the web directory of your symfony project to wherever you want it to be on your website (all on one line): ln -s /home/username/projects_directory/project_name/web /home/username/example.com
    3. When you list the directory's contents, you'll notice that this makes a link that looks like this: web -> /home/username/projects_directory/project_name/web, which displays at example.com/web, rather than at the top level of example.com. To fix that, go to the DreamHost control panel -> domains -> manage domains. Edit the web directory for the domain from /home/username/example.com to /home/username/example.com/web. Wait five to ten minutes for the changes to to populate, then refresh your browser at example.com. (Found that hint here.)

      If, for whatever reason, you typed the symlink in wrong, you can remove it by typing $ rm link_name (link_name in this case is web).

Et voilà! :)

Updates:

Aug. 15, 2007: added pear config-set commands (I-A-2 through I-A-4).

ETA: To view all installed pear packages from all channels, type $ pear list -a

ETA the second: I don't use symfony (this was pretty much just an exercise to see if I could get it to work correctly so I could evaluate it when I was looking at frameworks), so this tutorial won't be updated as the installation process for symfony changes. I'll leave it up, however, because it can still function as a starting place for figuring out what won't work when you're trying to install. :)

33 Comments

  1. I just come across this tutorial.
    Excellent, this is exactly what I was looking for.

    Thanks.

  2. herself says:

    You're most welcome, Simone. Glad you found it of use! :)

  3. Naud says:

    hi,

    I have installed a symfony app on DreamHost but it bugs (horrible "Oops! An Error Occurred
    The server returned a "500 Internal Server Error"." from the symfony 500 erro page that I did not customized). So I tried those steps that you provide.

    But, it bugs for me on step A I 2 (pear install -o PEAR)…

    I have error messages like:
    (…)Error: cannot download "pear/PEAR"
    (…)Error: cannot download "pear/Archive_Tar"(…)

    And when I try a which pear, I get :
    which pear
    /usr/local/php5/bin/pear
    (and not /home/myusername/pear/pear)

    Does it says something to you ?

    Is it important that my pear be
    /home/myusername/pear/pear instead of
    /usr/local/php5/bin/pear ?

    Thanx !

  4. Naud says:

    I solved step A I 2 doing that first :
    $ mkdir -p ~/tmp/pear/cache
    $ mkdir -p ~/tmp/pear/temp
    $ pear config-set download_dir ~/tmp/pear/cache
    $ pear config-set temp_dir ~/tmp/pear/temp

    Now I can access my pear !!

  5. Sito says:

    Would you happen to know how to install the askeet demo on dreamhost? I was able to run through what you wrote out in steps above but when trying to do day 24 of the askeet software package I'm not quite sure what's going wrong. Wondering if you had any luck.

    thanks for all the help

  6. Christopher Lewis says:

    Please never take this info down. It works like a charm.

  7. Eric says:

    I'm having the same problem as NAUD, I tried those extra steps but it still doesn't work, I was able to follow this tutorial successfully yesterday, but not today, I think Dreamhost has been messing with the servers, some of them are down today

  8. Herself says:

    Sito: I haven't tried to install the askeet demo, sorry. :( What's the error it's giving you? (No guarantees I know what it is, of course.)

    Naud & Eric: You know, I vaguely remember having an issue the first time (months and months ago) that I tried to install pear, and I remember editing the configuration directories for it. Try typing:

    pear config-show

    at the command prompt and see what it tells you. The *_dir directories should point to your locally installed version of pear, not the default, limited version installed for general use on the server. Ditto on the php5 directory.

  9. Herself says:

    Naud:

    Is it important that my pear be /home/myusername/pear/pear instead of /usr/local/php5/bin/pear ?

    Yeah, 'cuz the default installation of pear that DH does is a very limited version, and users can't modify what packages or what version is installed. (From the wiki: "Dreamhost includes only a bare set of PEAR modules on shared hosting accounts, and does not allow users to add more to the base install.")

    Oh! Looks like there are some steps in the pear installation that I did ages ago that I missed, which I see from rereading the wiki page. I'll add those steps above. :)

  10. Herself says:

    Thanks, Christopher! I'm glad it worked well for you. :) (Sorry, your comment got caught in the spam filter, so I didn't see it until tonight when I was cleaning that out.)

  11. Chris Bloom says:

    Just AWESOME! I spent about 4 hours last night trying to get Trac and SVN setup on Dreamhost (still no dice on Trac) by following their less-than-verbose DH wiki articles, but following this to set up Symfony and Pear took less than 30 minutes from start to finish! Thanks so much! Er, any advice on how to add SVN to the instructions above?

  12. mozey says:

    I dont understand why you have
    ~user/domain.com/web which points to your symfony /web directory. If you are going to change your settings in panel.dreamhost.com, you might as well make it point to
    ~/user/project/symfonyproject/web

    Cut the middle man, see what i'm sayin.

    THANK YOU FOR THE totorial, :) everything else works like a charm

  13. Herself says:

    Chris B: Thanks! Glad you found it useful. :) I haven't tried setting it up via SVN yet, but it shouldn't be that hard, I would imagine. (And yeah, the wiki articles really aren't very detailed. *g*)

    Mozey: Totally up to you. *g* (Although I suppose it could speed it up even a little tiny bit to do the direct link, but I'm not sure that the difference would be noticeable.) And you're most welcome! Glad you found it useful. :)

  14. Fropes says:

    This worked amazing for me as of today with Symfony 1.0.11. Thanks so much!

  15. m y says:

    Thank you so much for this page! Worked like a charm :].

  16. Sam Pablo Kuper says:

    This is a really helpful walkthrough, thanks!

    However, once I've got to the end of it and go to the correct URL in my browser, I get the error "Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/.pig/sampablokuper/symfony_projects/symfonytest001/web/index.php on line 10"

    I'd be grateful for any advice you can give. Thanks again!

  17. Sam Pablo Kuper says:

    Apologies – in the dreamhost panel under domains > manage domains I had the PHP for that domain set to 4.4.x

    That's why I was getting the error!

  18. […] followed the instructions on Chatteren's blog here, and they worked like a charm, although they omit to mention the need to ensure, on the Dreamhost […]

  19. josh says:

    [fresca]$ ln -s /home/xx/xyz/web /home/xx/xyz
    ln: `/home/xx/xyz/web': cannot overwrite directory

  20. I've never used PEAR, but as an alternative, I was able to use Subversion and Capistrano to handle deployment.

  21. inakivb says:

    YEAH!!

    I was trying everything for hours, and finally, i came here…

    And it works!

    Thaks!

  22. Jon says:

    Hi, when i write:

    pear install symfony/symfony

    The result is:
    downloading symfony-1.1.1.tgz …
    Starting to download symfony-1.1.1.tgz (2,131,490 bytes)
    …….done: 2,131,490 bytes
    Killed

    And symfony dont install.

    Please, what can i do? Thanks!

  23. Pro777 says:

    After banging my head trying to get Symfony configured properly on my Vista machine, this is an absolute Godsend! Thank yo so much.

  24. […] you need to install symfony application on DreamHost I recommend Chatteren's […]

  25. Flossy says:

    Just want to add to cacophony. This is an excellent tutorial that saved me what I assume would otherwise have been hours/days/weeks of digging for this information. Couldn't have been more thorough and easy to comprehend. Cheers to your altruism.

  26. Yon says:

    Amazingly well explained ;) THANKS

  27. Guillermo says:

    Thank you very much!!! Your tutorial is very useful!!

  28. Guillermo says:

    Hello!!
    I followed those steps and I could set my first symfony project on dreamhost.
    Then, I replace the server files with the files from my PC and my project is accessible now.
    The only problem is that images are broken.
    Could you help me please to fix the images problem?
    Thanks in advance.
    Guillermo

  29. Guillermo says:

    Hi, I apologize for that but my mistake was the case sentive of linux. I am working on windows and I forgot that difference.
    Thanks!!
    Guillermo

  30. Dhruv says:

    Hey, Do you have any plan for writing installation instructions for Symfony2 as well?

    • Annie says:

      Nope, sorry–I wrote this up when I was checking out frameworks and had problems finding info on how to get Symfony installed easily. (That reminds me, though–I need to do an nginx/fcgi/Django installation write up. *g*)

Leave a Reply