Dispatch.fcgi and ruby ​​on racks using rvm

I'm trying to just get the "hello world" application running on my hosting service (Dreamhost) using rvm . I use rvm to use Ruby 1.9.2 and Rails 3.1

I understand that there are better hosting environments and better ways to do this, but so far I have been thinking that I will try to fight and try to do this job.

I have a cgi script work which shows that rvm is working fine: http://rails.hortitude.com/foo.cgi

#!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290 puts "Content-Type: text/html" puts puts "<html>" puts "<body>" puts "<h1>Hello Ruby!</h1>" puts "<p>shebang: #!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290</p>" puts "<p>RUBY_VERSION: " + RUBY_VERSION + "</p>" puts "<p>RUBY_PLATFORM: " + RUBY_PLATFORM + "</p>" puts "<p> RUBY_RELEASE_DATE: " + RUBY_RELEASE_DATE + "</p>" puts "</body>" puts "</html>" puts "</html>" 

However, my dispatch.fcgi script always gives me an error (found in error logs)

Premature end of header script: dispatch.fcgi

Here is my dispatch.fcgi script:

 #!/usr/bin/env /home/hortitude/.rvm/bin/ruby-1.9.2-p290 ENV['GEM_HOME'] ||= '/home/hortitude/.rvm/gems/ruby-1.9.2-p290' require 'rubygems' require 'fcgi' ENV['RAILS_ENV'] ||= 'production' # Set GEM_PATH and GEM_HOME ("user" is your dreamhost user) ##ENV['GEM_HOME'] ||= '/home/user/.gems' require 'rubygems' Gem.clear_paths 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 Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(Helloworld::Application) 
+4
source share

Source: https://habr.com/ru/post/1390664/


All Articles