Ruby on Rails, nginx, passenger on production server (cannot load such file — rubygems/path_support)

前端 未结 3 985
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 08:49

I installed:

  • Centos 6
  • Ruby 1.9.3-rc1
  • Passenger gem and passenger nginx module ( compiled against own source 1.1.6)
  • Installed rails 3
相关标签:
3条回答
  • 2021-01-16 08:59

    In my case, I also met this problem:
    ( My environment: Centos 5.8, rbenv 1.9.3p327, passenger 3.0.19, nginx( compiled and installed by passenger) . I googled around but didn't find any direct answer ( keyword: rbenv, passenger, cannot load such file -- rubygems/path_support), so I write my solution here.

    I have checked and set nginx user to root, not works. and changed all the privileges of gem folder to 777. not works.

    finally I got the solution: add these 2 lines of code to your Nginx config file:

    passenger_default_user root;
    passenger_default_group root;
    

    so now your nginx config file looks like:

    # /opt/nginx/config/nginx.conf
    user  root;  # seems this line of code doesn't take effect.
    http {
      passenger_root /root/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/passenger-3.0.19;
      passenger_ruby /root/.rbenv/versions/1.9.3-p327/bin/ruby;
    
      # these lines are the key!!!
      passenger_default_user root;
      passenger_default_group root;
    
      server {
        listen 80;
        root <your_rails_project_public_folder>;
        passenger_enabled on;
      }
    }
    
    0 讨论(0)
  • 2021-01-16 08:59

    I had a same problem. Timo is right.

    your application must set /home/rvm_user/ directory.

    example:

    # vi /etc/conf/httpd.conf
    LoadModule passenger_module
    /home/rvm_user/.rvm/gems/ruby-1.9.3-rc1/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
    PassengerRoot /home/rvm_user/.rvm/gems/ruby-1.9.3-rc1/gems/passenger-3.0.9
    PassengerRuby /home/rvm_user/.rvm/wrappers/ruby-1.9.3-rc1/ruby
    
    <VirtualHost *:80>
    ServerName www.yourhost.com
    DocumentRoot /home/rvm_user/your_application/public
    <Directory /home/rvm_user/your_application/public>
    AllowOverride all
    Options -MultiViews
    </Directory>
    </VirtualHost>
    
    # chmod 755 /home/rvm_user/
    
    # /etc/rc.d/init.d/httpd restart
    
    0 讨论(0)
  • 2021-01-16 09:05

    I had a similar problem, though I had rvm and ruby installed only for one user. For me, the solution was to check that the application files were owned by the same user for which ruby was installed.

    http://www.modrails.com/documentation/Users%20guide%20Nginx.html#user_switching

    0 讨论(0)
提交回复
热议问题