Hello Tyson!

Welcome to DreamHost! (Heh.) DreamHost can be a challenge to get a 
handle on. Here's a few quick tips you really need to know.

Get Radiant running under dispatch.cgi. By doing this, you will know you 
have Radiant working. When you do this, you will get more verbose errors 
in the log as well, which you will find is a godsend.

Shell will become your friend. Make sure you know how to shell into 
DreamHost

Make sure you have your rubygem install up and running. You will need 
this. When you do get it up, make sure your .bash_profile has the 
following in it based on where you installed your gems (I did it into 
.gems so it's not in my directory list all the time): (Here's a link to 
help you set it up http://wiki.dreamhost.com/RubyGems )

export PATH="$HOME/bin:$PATH"
export RUBYLIB="$HOME/local/lib/site_ruby/1.8"
export GEM_HOME="$HOME/.gems"
export GEM_PATH="/usr/lib/ruby/gems/1.8:$GEM_HOME"
export PATH="$HOME/.gems/bin:$PATH"

This ensures that when you run 'gem' that it uses your local version, 
and that --MOST-- (Not all, keep reading) applications uses your gems first.

gem install radiant -- That will get you the newest version, and ensure 
your rubygem install is working under shell.

Now, a big issue with how they have apache set up is that it does not 
regard your .bash_profile, .gemrc or otherwise when under FastCGI. This 
being said, you have to make Apache recognize your Radiant gem install

Head into http://panel.dreamhost.com/ and go to Domains->Manage Domains. 
Make sure you have your domain set up with the following settings:

Extra Web Security: Yes
FastCGI Support: Yes
Specify web directory: domain.com/public (Change domain.com to whatever 
directory your web host will be in. Can't)

While you're in the panel, make sure you have a MySQL database up and 
know the username/password.

Head into the shell and go into the domain.com/ folder (Or whatever you 
called it - Don't go into the public folder, if it is there.) Run the 
following command:

radiant ./ --ruby=/usr/bin/ruby --database=mysql

This will generate the directories and get them up and running for you. 
Radiant won't be ready yet though. From here, head into config/ and edit 
database.yml (pico works fine) You want to change the database, 
username, password, AND add host: if it is not there, on both 
development and production. In the host portion, you need to put 
mysql.domain.com (It will be the first domain name you put with 
dreamhost unless you've set up otherwise.) -- They do not host the MySQL 
database on the same system as the apache (Heck, your files aren't even 
technically on that server, they have those on a remote fileserver. All 
your server is, is a process center for running Apache.)

Close that file, and edit environment.rb. Add these three lines to the 
top of the file:

ENV['RADIANT_ROOT'] = '/home/myhome/.gems/gems/radiant-0.6.1'
ENV['GEM_HOME'] = '/home/myhome/.gems'
ENV['GEM_PATH'] = '/home/myhome/.gems:/usr/lib/ruby/gems/1.8'

myhome will be the same as your username you use to log into shell. If 
you didn't install rubygem to .gems, make sure you change that too.

Go down a few lines from there, and change the ENV['RAILS_ENV'] line to

ENV['RAILS_ENV'] ||= 'production'

While development is fine for most other hosts, development seems to get 
canned very often by DreamHost, so you might as well deal with the 
little hassles linked to using 'production' - It's not as bad to use on 
dreamhost anyways; To restart apache in this instance, you would simply 
touch dispatch.fcgi to restart Radiant(Apache) anyways.

Now, you may or may not have to tweak some of the rest of the 
environment file. I can't remember if you do.

Close and save that, and then head back to your main directory and head 
into public folder. Add the following lines at the very bottom of the 
file to help minimize 500 errors caused by DreamHost canning your 
process mid-serving. There is a plug-in that apparently works really 
well; I use it, but it hangs the whole thing up more than it saves from 
500s.

class RailsFCGIHandler
  private
    def frao_handler(signal)
      dispatcher_log :info, "asked to terminate immediately"
      dispatcher_log :info, "frao handler working its magic!"
      restart_handler(signal)
    end
    alias_method :exit_now_handler, :frao_handler
end

Also, make sure that the path to ruby got put in properly at the top: 
#!/usr/bin/ruby

Make sure in your .htaccess in that folder that you have AddHandler 
fastcgi-script .fcgi uncommented and that you changed the final 
RewriteRule to

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Now, one major thing you will need to do to help minimize DreamHost's 
automated process canner (Set at 200MB memory usage or appear 'runaway', 
which is pretty loose term by them.) -- You will need to make sure you 
have any files hosted in your /public folder be under a RewriteCond 
similar to this:

RewriteCond %{REQUEST_URI} ^/javasript/(.*)$

You need to do this for all your images, javascript files, favicon.ico, 
and so forth. Any file that would be directly accessed by HTML, you need 
it away from the Ruby on Rails dispatcher. If you don't do that, you 
will be having your memory constantly running up to and over 200MB, 
causing dreamhost to can your process with no warning, forcing a lengthy 
'reboot' of dispatch.fcgi, during which you will get an army of '500' 
errors. An alternate route that I have chosen is by having a second host 
to be home to my website files such as my images and such. This means 
you only need to make enough RewriteCond's to handle what is in place: 
This is my current list of Rewrites for this purpose:

RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/javasript/(.*)$
RewriteCond %{REQUEST_URI} ^/favicon.ico$
RewriteCond %{REQUEST_URI} ^/images/(.*)$
RewriteCond %{REQUEST_URI} ^/stylesheets/(.*)$
RewriteCond %{REQUEST_URI} ^/robots.txt$

You want to put this below RewriteBase /

DreamHost states they are Ruby on Rails-friendly, but their setup 
doesn't lend well to this. They have set up --5-- dynamic dispatch.fcgi 
that will launch on your site, causing a plethora of issues; 200MB x 5 
-> 1GB RAM. They will can everything of yours when it hits a certain 
point, and if you have all 5 of your dispatchers flooded, rather than 
your site going down temporarily until requests slow down (Like what 
would happen with 2 static dispatchers.) Dreamhost will happily 
continuously can your processes, INCLUDING shell processes until it is 
happy you are no longer being a hog. This has happened to me twice. Not 
pleasant. You're essentially down until you have NO web traffic by this 
point; Once took me over 5 hours and turning off the hosting temporarily 
in the Panel. These 'bursts' in memory usage would be caused by Ruby on 
Rails getting every single request for a file, even those that it 
doesn't control, and it having to handle them. If you put the 
RewriteCond's in place, it will simply allow Apache to handle them 
itself rather than going through the dispatcher, leaving the dispatcher 
to handle the issue itself.

Now, another thing to keep in mind; I don't know if it is a Radiant or 
DreamHost issue yet, but I'm getting ~2000 hits a day, and sometime 
during that day, my cache gets bungled somehow and you'll get an Apache 
error, stating something to the effect that something happened. When 
this happens, you need to go into http://www.domain.com/admin/pages/ and 
click the 'Clear Caches' to fix this issue up. Sometimes you may need to 
go into the shell and do a 'touch dispatch.fcgi' in the 
domain.com/public/ folder to reset Apache. It is a nuisance for sure, 
but it's far less often than the 500 errors that you'll get if you don't 
manage your .htaccess well.

Another tip: Unless you are hung badly, avoid using killall -9 
dispatch.fcgi: Apache is set on a very long timer (5minutes+) for 
timeout on the dispatchers, and you will be pulling your hair out trying 
to figure out what Apache is not bringing the dispatchers back up. 
Always use touch dispatch.fcgi unless that is not working; Touch will 
work in most cases unless you have a major issue.

I hope I haven't forgotten anything. This should get you up and running. 
As mentioned before, I recommend running off of .cgi instead of .fcgi to 
make sure it isn't Radiant being a pain. Check the logs; They will tell 
you a lot when you're under .cgi. When you have all the above in place 
(Some of above specifically pertains to dispatch.fcgi BTW.) give the 
.fcgi a try.

I hope this helps. I wrote out the entire procedure I did for you and 
others having issues. I know you likely know a good portion of this 
already; A lot of these steps I had to come up with on my own.

Lemmie know if you need more help!
Andrew
BladedThoth.com

Tyson Evans wrote:
> I had great success with Radiant on a previous Web host, but switched
> to Dreamhost for more robust hosting features.
>
> Have been trying to get Radiant running with no luck. Haven't found a
> fix in various mailing list posts or the wikis.
>
> Currently attempting to troubleshoot using dispatch.cgi versus
> dispatch.fcgi (unsure why this is being returned @
> http://www.tysonevans.com/cv ). dispatch.fcgi hangs and returns a
> Rails application error.
>
> When attempting to use dispatch.fcgi the error log file returns:
>
> [error] FastCGI: comm with (dynamic) server
> "/home/.pygmy/tysone/tysonweb/public/dispatch.fcgi" aborted: (first
> read) idle timeout (60 sec)
> [error] FastCGI: incomplete headers (0 bytes) received from server
> "/home/.pygmy/tysone/tysonweb/public/dispatch.fcgi"
>
> Running dispatch.fcgi or dispatch.cgi via SSH returns:
>
> -bash: dispatch.cgi: line 3: syntax error near unexpected token `('
> -bash: dispatch.cgi: line 3: `require File.dirname(__FILE__) +
> "/../config/environment" unless defined?(RAILS_ROOT)'
>
> This is way beyond me... but I'd appreciate any tips on possible fixes.
> _______________________________________________
> Radiant mailing list
> Post:   [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
>   

_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to