Redmine on Dreamhost with Passenger

May 16th, 2008

Dreamhost LogoAs of May 13, 2008 Dreamhost provides a feature called Passenger for Ruby on Rails. This make is significantly easier to install Ruby On Rails Apps on Dreamhost!!!

The following is how I install Redmine on Dreamhost with Passenger

  1. From the Dreamhost control panel, create a new subdomain for the application such as yoursubdomain.yourdomain.com
    1. Make sure the domain supports “Ruby on Rails Passenger (mod_rails)?”
    2. Specify your web directory: /home/username/yoursubdomain.yourdomain.com/public
      • you must add the public!!!
  2. From the Dreamhost control panel create a new MySQL database named yourdatabasename
  3. ssh into your Dreamhost account
  4. cd ~/yoursubdomain.yourdomain.com
  5. svn export --force svn://rubyforge.org/var/svn/redmine/branches/0.7-stable ./
    • check http://www.redmine.org/wiki/redmine/Download for the latest version
  6. also watch out for permissions
    • chmod -v -R 755 ./*
  7. cd ~/yoursubdomain.yourdomain.com/config
  8. cp database.yml.example database.yml
  9. nano database.yml
    1. edit the database.yml config file with the appropriate info. Should be similar to the following
      production:
      adapter: mysql
      database: yourdatabasename
      username: yourusername
      password: yourpassword
      host: mysql.yourdomain.com
  10. cd ~/yoursubdomain.yourdomain.com/public
  11. cp dispatch.rb.example dispatch.rb
  12. nano .htaccess (replace with following text)
    Options +FollowSymLinks +ExecCGI
    RewriteEngine On
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    ErrorDocument 500 “<h2>Application error</h2>Rails application failed to start properly”
  13. cd ~/yoursubdomain.yourdomain.com
  14. from application root type
    • rake db:migrate RAILS_ENV="production"
  15. also type the following to load config defaults
    • rake redmine:load_default_data RAILS_ENV="production"
    • choose “en” for english
  16. browse to http://yoursubdomain.yourdomain.com

Reference

http://www.redmine.org/wiki/redmine/RedmineInstall
www.jorgeivanmeza.com

http://www.redmine.org/boards/2/topics/show/69
http://wiki.dreamhost.com/Passenger

12 Responses to “Redmine on Dreamhost with Passenger”

  1. Chris Pitzer Says:

    I ran into a problem where my RedMine install was displaying only in plain text. It wasn’t serving the static files (CSS, Images, etc) that make it look like a normal webpage. The following is how I fixed the problem - hope this helps someone!

    1 - ssh into yoursubdomain.yourdomain.com
    2 - run the following commands to build and implement a fresh .htaccess file.
    ruby rortest
    cp rortest/public/.htaccess public/
    3 - run the following commands to restart redmine.
    cd tmp
    echo ‘x’ > reboot.txt

    That did it for me. Good luck!

  2. Chris Pitzer Says:

    It looks like DreamHost likes to kill RedMine after a minute or two of inactivity. This makes the next page load subject to a 30 second wait as redmine is restarted.

    Any ideas on how to get around this…? Faster load times? Or a way to keep the app from stalling?

  3. daveline Says:

    You try setting up a cron job to “ping” the application to keep it alive.

    crontab -e */15 * * * * curl -s http://www.yourhost.com/your_non_cached_file/ > /dev/null

    See dreamhost wiki for details
    http://wiki.dreamhost.com/index.php/Ruby_on_Rails

  4. daveline Says:

    I think you meant
    rails rortest
    not
    ruby rortest

  5. daveline Says:

    I think it is actually restart.txt not reboot.txt

  6. David Says:

    A few little issues I came across:

    It seems like passenger and fastcgi aren’t best of friends. I couldn’t get it running unless I turned off fastcgi. (a bit frustrating as Dreamhost’s wiki says to turn on fastcgi for RoR apps)

    Also, what are the caveats with using an svn export as opposed to svn checkout? I’m assuming that the main issue is that updating won’t be as easy? or do you simple export again to the same directory?

  7. daveline Says:

    With dreamhost, I never mix RoR apps with other apps that might need FastCGI support, so I turn off the FastCGI, and turn on the mod_rails. I assume the Dreamhost wiki was just a little out of date, since mod_rails is a relatively new thing.

    I never really thought much about the SVN Checkout/Export intricacies. I just don’t like having all the “.svn” information in my production (public viewable app). It kinda felt dirty & like a potential security risk. I know the official redmine docs says to use co (checkout), and this does make it very easy to update the app. I currently manually update the app, which involves, backing it up, deleting the existing app, doing another export, and copying the config files/uploaded docs/other pertinent data back. Wow that seems like a lot of work, but I do feel it is important to remove the potential old files, and not just do another export. Not removing the extra files could lead to a potential security risk. Also if you just do an export, you may overwrite your existing config. So much for my 5 nines of uptime. ;) I may document and post my exact update steps, next time I have to do it.

    I did a quick search on Google to see if I was crazy for using export instead of co and found this.
    http://www.rubyinside.com/capistrano-security-issue-svn-info-often-publicly-viewable-415.html

  8. daveline Says:

    In a non-dreamhost world you can add a few lines of code to your apache’s httpd.conf to prevent Apache from serving the .svn directories.
    http://subversion.tigris.org/faq.html#website-auto-update

    On dreamhost you may be able to do something with the .htaccess file. See this
    http://www.webmasterworld.com/apache/3189079.htm

  9. Jose Diaz-Gonzalez Says:

    Can you post instructions on how to setup svn with dreamhost? I mean, having multiple repositories for each project automatically. I’ve never set up svn before and from the page on the dreamhost wiki, it appears to make it so that I have to set up a repository for each project in Redmine. Is that true or am i just reading it incorrectly?

  10. Jose Diaz-Gonzalez Says:

    nvm, I understand SVN a little more and realize I’ll have to setup each one myself.

    Can you explain what the non-cached file is in the crontab command? I’m having troubles with long load times as well.

  11. jiminy Says:

    No need to tinker with dispatch.rb or .htaccess or pings to keep the app alive if you use Passenger. Passenger doesn’t need any of these, and it disables rewrites.

    Also note that you need to unpack redmine before you set up Passenger hosting or you’ll get an error message in the panel. Passenger expects a ready-to-go Rails app before the subdomain can be created.

    And I wouldn’t name that directory after the domain if it isn’t the www-root for the domain. That’s confusing. I’d just call it ~/redmine (or ~/redmine-0.7) and either host the subdomain at ~/redmine/public/ or create a symlink ~/subdomain.domain.tld that redirects there. But that’s a matter of taste.

  12. jiminy Says:

    Oh, I see what the .htaccess thing is about. The .htaccess that comes with Redmine breaks the paths to scripts and CSS.

    With Passenger, just delete public/.htaccess, restart and you’re fine.

Leave a Reply

Spam protection by WP Captcha-Free