0

I do not have much experience with Rails. Back on Wednesday I was told to upgrade Redmine, and upgrade the plugins. I've been working on this for 3 days now and it has been a shock to see how far Rails still has to go to enter the modern era of package management.

I am on Centos 6.3. At first I upgraded to Ruby 1.8.7 because that is what is in the Centos repository, and that was enough to upgrade Redmine. But when I got to the redmine_backlogs plugin, I realized I needed a newer version of Ruby. Getting Ruby 1.9.3 on Centos is not easy. I tried 4 different tutorials before I got something that worked. I have a ton of strange paths that I have had to fix manually.

I tried Nginx with Passenger and could not get it to work, so later I did Phusion Passenger Standalone.

Now I've got Rails 3.2.11 running. I suppose I'll have to patch this given all the security problems in the land of Rails these last few weeks.

I just upgraded to the newest Redmine, which should be 2.2.

I think my Nginx is using a different version of Ruby than what I want. If I do this:

/opt/nginx/sbin/nginx -V

then I see this:

    built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)            
    TLS SNI support enabled                                                        
    configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --with-pcre=/tmp/root-passenger-14193/pcre-8.31 --add-module=/usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/ext/nginx

Which looks like it is using Ruby 1.8 instead of Ruby 1.9.3, yes?

If I do this:

/opt/nginx/sbin/nginx -s stop

and then:

/opt/nginx/sbin/nginx

I restart nginx but if I then refresh in my browser, I get:

Passenger encountered the following error:
The application spawner server exited unexpectedly: Unexpected end-of-file detected.

Exception class:
PhusionPassenger::Rack::ApplicationSpawner::Error
Backtrace:
#   File    Line    Location
0   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    135 in `start'
1   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   253 in `spawn_rack_application'
2   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  132 in `lookup_or_add'
3   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   246 in `spawn_rack_application'
4   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  82  in `synchronize'
5   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  79  in `synchronize'
6   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   244 in `spawn_rack_application'
7   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   137 in `spawn_application'
8   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   275 in `handle_spawn_application'
9   /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 357 in `__send__'
10  /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
11  /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
12  /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.19/helper-scripts/passenger-spawn-server    99  

I have seen a comment from here related with this issue:

i solved the problem after checking several installation procedures (god bless vm's and snapshots). the normal useraccount and the apache user uses another ruby version (1.8) then root does (1.9.3). now everything works fine.

but I would not know how to fix it on my server.

I tried to look in my Nginx logs:

tail /var/log/nginx/error.log

but the most recent error is from February 5th, so I suspect that once I switched over to using Phusion Passenger, the error logs were moved to a new location, but I am not sure how to find the location where Nginx stores its error log, now that Phusion Passenger is controlling it. Any suggestions?

UPDATE:

I found the new Nginx error log here:

/opt/nginx/logs/error.log

The errors are:

2013/02/11 17:02:15 [notice] 25295#0: signal process started
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

2013/02/11 17:06:23 [notice] 25360#0: signal process started
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

2013/02/11 17:10:47 [notice] 25433#0: signal process started
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

2013/02/11 17:13:35 [notice] 25522#0: signal process started
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

2013/02/11 17:16:31 [notice] 25598#0: signal process started
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

If I do this:

echo $PATH, then:

/usr/local/rvm/gems/ruby-1.9.3-p385/bin:/usr/local/rvm/gems/ruby-1.9.3-p385@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p385/bin:/usr/local/rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin

From Passenger docs page:

The default value is ruby, meaning that the Ruby interpreter will be looked up according to the PATH environment variable.

So you would think it would use ruby 1.9.3 instead of 1.8

If I look in config.ru, I see:

require::File.expand_path('../config/environment',  __FILE__)
run RedmineApp::Application

Any suggestions?

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
cerhovice
  • 676
  • 1
  • 10
  • 24

1 Answers1

0

Phusion Passenger for Nginx

The Ruby interpreter is purely determined by the passenger_ruby directive. Nothing else. Change it and it'll work as expected. This works even if you originally installed Phusion Passenger using a RubyGems belonging to a different Ruby version.

In versions prior to 4.0.0, only a single Ruby version was supported for the entire Nginx instance, so passenger_ruby may only occur in the global server configuration.

Since version 4.0.0 (currently in Release Candidate), Phusion Passenger supports multiple Ruby or Python interpreters in the same Nginx instance. And so, since version 4.0.0, this option may occur in the following places:

  • In the 'http' configuration block.
  • In a 'server' configuration block.
  • In a 'location' configuration block.
  • In an 'if' configuration scope.

The passenger_ruby in the http block - that is, the one that passenger-install-nginx-module outputs - is used as the default Ruby interpreter for Ruby web apps. You don't have to specify a passenger_ruby in the http block though, because the default is to use the first ruby command found in $PATH.

You can also override passenger_ruby or passenger_python in specific contexts if you want to use a different Ruby interpreter for that web app. For example:

http {
    passenger_root ...

    # Use Ruby 1.8.7 by default.
    passenger_ruby /usr/bin/ruby1.8
    # Use Python 2.6 by default.
    passenger_python /usr/bin/python2.6

    server {
        # This Rails web app will use Ruby 1.8.7
        listen 80;
        server_name www.foo.com;
        root /webapps/foo/public;
    }

    server {
        # This Rails web app will use Ruby 1.9.3, as installed by RVM
        passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3/ruby;

        listen 80;
        server_name www.bar.com;
        root /webapps/bar/public;

        # If you have a web app deployed in a sub-URI, customize
        # passenger_ruby/passenger_python inside a `location` block.
        # The web app under www.bar.com/blog will use JRuby 1.7.1
        passenger_base_uri /blog;
        location /blog {
            passenger_ruby /usr/local/rvm/wrappers/jruby-1.7.1/ruby;
        }
    }

    server {
        # This Flask web app will use Python 3.0
        passenger_python /usr/bin/python3.0;

        listen 80;
        server_name www.baz.com;
        root /webapps/baz/public;
    }
}

Phusion Passenger Standalone

The Ruby interpreter is purely determined by the Ruby interpreter that you've used to start the passenger command. Change it and it'll work as expected. This works even if you originally installed Phusion Passenger using a RubyGems belonging to a different Ruby version.

Hongli
  • 18,682
  • 15
  • 79
  • 107