Rails 3.2.8 ruby ​​1.9.3 on DreamHost shared hosting fcgi Question RMagic

Using the following guide

http://spontaneousderivation.com/2012/09/30/rails-3-2-on-a-shared-dreamhost-server/

I managed to get the Rails 3.2.8 application with Ruby 1.9.3 and run it on Dreamhost hosting using fcgi (I know that this is not the best solution, but I do not want to downgrade my applications to 3.0 and I do not have enough skills and money for VPS) .

Following the DH wiki guides:

http://wiki.dreamhost.com/RMagick

http://wiki.dreamhost.com/Image_Magick#Compiling_ImageMagick_on_your_DreamHost_account

I installed my own version of ImageMagic and RMagic as a local gem.

However, when I try to start the application using the RMagic function, I get the following error in error.log:

'Premature end of script headers: dispatch.fcgi'.

I found out that this happens when I uncomment the following line in my bootloader:

include CarrierWave::RMagick 

Running dispatch.fcgi from the shell does not report any errors.

I suppose the problem might be caused by LD_LIBRARY_PATH or other env variables (listed in the DH wiki), but tried to include them in my .bashrc , .bash_profile and dispatch.fcgi , but without effect.

+4
source share
2 answers

This decision is valid from 3/7/2013. I just used it to deploy a new application in DH.

In your gemfile ...

 gem 'paperclip' 

Then run "bundle install" from your application directory.

In your public /dispatch.fcgi ... copy the code below and replace APPNAME with the name specified in your module config / application.rb, USER with the username DH and RUBY with the specific version of ruby ​​specified in the output from "which ruby" at a command prompt on a DH ssh session.

 #!/home/USER/.rvm/rubies/RUBY/bin/ruby ENV['RAILS_ENV'] ||= 'production' ENV['HOME'] ||= `echo ~`.strip ENV['GEM_HOME'] = File.expand_path('~/.rvm/gems/RUBY') ENV['GEM_PATH'] = File.expand_path('~/.rvm/gems/RUBY') + ":" + File.expand_path('~/.rvm/gems/ RUBY@global ') require 'fcgi' require File.join(File.dirname(__FILE__), '../config/environment.rb') 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(APPNAME::Application) 

No special processing is required to get paperclip working, provided you have a valid RVM installation installed. Apart from the above features (in particular, dispatch.fcgi has been slightly modified), you can follow this guide, http://spontaneousderivation.com/2012/09/30/rails-3-2-on-a-shared-dreamhost-server / .

+2
source

RMagick and ImageMagick are known to have compilation / execution issues. I recommend the RMagick ditch in favor of something like a MiniMagick. It looks like CarrierWave has a MiniMagick processor that you can use instead: https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/processing/mini_magick.rb

MiniMagick simply outputs directly to ImageMagick processes, so you avoid the problems of binding to compiled binaries. RMagick used to be a source of memory leaks, etc.

In addition, you should seriously consider Heroku for deployment. One dinu is free, and I'm sure your experience will be much better.

+1
source

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


All Articles