Shared Server Dreamhost

Posted by Jseb on Stack Overflow See other posts from Stack Overflow or by Jseb
Published on 2012-12-13T23:02:48Z Indexed on 2012/12/13 23:03 UTC
Read the original article Hit count: 445

I am trying to install an app on a shared server. If i understand properly because i am using a shared server, and that Dreamhost doesn't suppose rails 3.2.8 I must use FCGI, although i am not sure how to install and to make it run properly.

From this tutorial http://wiki.dreamhost.com/Rails_3.

To my understand here what I did,

  1. In dreamhost, activate PHP 5.x.x FastCGI and made sure Phusion Passenger is unchecked
  2. Create an app on my localmachine
  3. Because rails doesn't create a dispatch and access file i create the two following file in my /public folder

dispatch.fcgi #!/home/username/.rvm/rubies/ruby-1.9.3-p327/bin/ruby

ENV['RAILS_ENV'] ||= 'production'
ENV['HOME'] ||= `echo ~`.strip
ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/ruby 1.9.3-p327')
ENV['GEM_PATH'] = File.expand_path('~/.rvm/gems/ruby 1.9.3-p327') + ":" +
    File.expand_path('~/.rvm/gems/ruby 1.9.3-p327@global')

require 'fcgi' 
require File.join(File.dirname(__FILE__), '../config/environment')

class Rack::PathInfoRewriter
 def initialize(app)
   @app = app
 end

 def call(env)
   env.delete('SCRIPT_NAME')
   parts = env['REQUEST_URI'].split('?')
   env['PATH_INFO'] = parts[0]
   env['QUERY_STRING'] = parts[1].to_s
   @app.call(env)
 end
end

Then created the file .htaccess

<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>

Options +FollowSymLinks +ExecCGI 

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L] 

ErrorDocument 500 "Rails application failed to start properly"
  1. Uploaded to a folder and pointed to the public folder in dreamhost
  2. Made sure dispatch.fcgi has 777 for write
  3. ssh and run the following command in the public folder : ./dispatch.fcgi
  4. Crossing my finger but it doesn't work I get the following errors

    ./dispatch.fcgi: line 1: ENV[RAILS_ENV]: command not found ./dispatch.fcgi: line 1: =: command not found ./dispatch.fcgi: line 2: ENV[HOME]: command not found ./dispatch.fcgi: line 2: =: command not found ./dispatch.fcgi: line 3: syntax error near unexpected token (' ./dispatch.fcgi: line 3:ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/ruby 1.9.3-p327')'

Doing wrong??? Oh and if i go on the server i get this Rails application failed to start properly

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby