Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a Rails app to Dreamhost?

I'm kind of lost, I try to deploy my application on a shared dreamhost server. Now everything works fine locally. It's my first try at Rails, and I'm not really a programmer or sysadmin, just hacking something together.

On Dreamhost, if I start webrick, it works fine on port 3000, but webricks gets killed pretty quickly, I guess that makes sense.

So what do I have to do to make it run?

I enabled fastcgi support and mod_rails.

Now, how do I get the app constantly running?

I keep reading about having to do things to .htaccess and to dispatch.fcgi.

But I can't find any dispatch file in my rails app (2.3.2).

Do I have to create that one manually? Doesn't really feeld very rails-like to me. I didn't really manage to find out what this dispatch file does, and why it's needed.

Any help would be greatly appreciated.

I looked at the DH Wiki, but couldn't figure it out (http://wiki.dreamhost.com/Rails)

Additions:

I enabled mod_rails and pointed to the public directory (I had already done that). I keep getting an error: screencast.com/t/KamqVawk

Hm, server logs look like there is actually no request, so this might be a problem on dreamhosts end. It's strange I see that the access.log show a new change date, when I try to access the page, but there is no request noted, error.log is empty too.

screenshot of configuration

Dreamhost Support Answer:

The server was up to date, so that wasn't the problem. They proposed freezing the Gems, which I did (see: http://wiki.dreamhost.com/Freezing_Gems) But it didn't help. I guess I'm giving up, and looking into hosting which is specialized for rails.

Thx for all your help!

Changed to hostingrails.com

I got the app working on hostingrails.com, passenger on hostingrails.com showed me errors, which weren't shown by dreamhost or mongrel. By correcting these errors, I got the app working.

like image 585
Roland Studer Avatar asked Jun 12 '09 14:06

Roland Studer


1 Answers

Dreamhost won't let you use webrick if you're using shared hosting. You can either use FastCGI or Passenger to host Rails on shared DH (mongrel is an option if you upgrade to DreamhostPS, but that's obviously more expensive).

For FastCGI, you will need a dispatch.fcgi file (older versions of Rails would generate one when you created a new Rails app, but that stopped around 2.2 if I remember correctly) as well as code in your .htaccess to send requests to the dispatcher. See the Dreamhost Ruby on Rails wiki page for details about setting up FastCGI.

The more preferable option is to set up your application to run on Phusion Passenger (aka mod_rails). It should be pretty simple through your Dreamhost panel, you just need to enable the domain to use mod_rails, and then set the directory for the domain to the public directory of your application. See the Passenger wiki page for more details.

like image 184
Daniel Vandersluis Avatar answered Sep 19 '22 21:09

Daniel Vandersluis