FCGI example setup for Apache + Ruby on Rails

Hi,

first post in the forum, I hope I found the right category.

I try to set up an redmine installation on an managed server with linux/apache, I’m not very familiar with ruby and rails.

I managed to install all the gems and following the install guide I finished the installation. Redmine works with the webrick server.

No I have problems with the FCGI integration, I always get an Error 500. I followed the instructions from my hosting company and the redmine docs - no success.

So the next step is to create a simple “hello world” ruby/rails/fcgi/apache test application.

My .htaccess is:
AddHandler fcgid-script .fcgi

RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"

my dispatch.fcgi is:
#!/bin/dash
export GEM_HOME="$HOME/.gem/ruby/2.3.0/"
export GEM_PATH="$GEM_HOME:/var/lib/ruby/gems/1.8"
exec /usr/bin/ruby /usr/www/users/admin/test/hello.rb

And hello.rb:
puts ‘Hello World!’

Didn’t work, I got the Error 500. What’s wrong or missing?

Thanks for any tipps
Klaus

Hey Klaus,

Check the REDMINE_ROOT/log/production.log and if that information couldn’t help you, please provide its content here.

Sorry for the late reply - no entries in the production log, it failed before logging.

But with much time and help from my provider I solved this. If anyone in the future has the same problem - here is my configuration:

.htaccess is:

FcgidWrapper /usr/www/users/admin/redmine/ruby_handler.fcgi .rb
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ ruby_handler.fcgi [QSA,L]

ruby_handler.fcgi is:

#!/bin/dash
#export GEM_HOME="$HOME/.gem/ruby/2.3.0/"
#export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/2.3.0"

export HOME="/usr/home/admin"
export GEM_HOME="$HOME/.gem/ruby/"
export GEM_PATH="/usr/home/admin/.gem/ruby/2.3.0/"

exec /usr/bin/ruby /usr/www/users/admin/redmine/startup.rb

startup.rb is:

require_relative ‘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
env[‘HOME’] = “/usr/home/admin/”
@app.call(env)
end
end

Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(RedmineApp::Application)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs