used to have this list of rubies in my vps:
ruby-1.9.2-p320 [ i686 ] =* ruby-1.9.3-p194 [ i686 ] ruby-1.9.3-p374 [ i686 ] ruby-1.9.3-p392 [ i686 ]
today I installed a new app on this vps on ruby 2.0
, so I added 2.0 to rvm
:
ruby-1.9.2-p320 [ i686 ] ruby-1.9.3-p194 [ i686 ] ruby-1.9.3-p374 [ i686 ] ruby-1.9.3-p392 [ i686 ] =* ruby-2.0.0-p247 [ i686 ]
installed passenger
and passenger-apache-module
, instructions says to add these lines:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
to /etc/apache2/apache2.conf
and restart apache, after restart I got this error:
Syntax error on line 242 of /etc/apache2/apache2.conf: Invalid command 'PassengerDefaultRuby', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed. The Apache error log may have more information. ...fail!
and one more problem, when I open my app at http://nccm.md I got:
Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
from gem list
command I can see this gem is installed in ruby 2.0 environment, but the app looks for it in usr/local/rvm/gems/ruby-1.9.3-p194@global
. Why is that? Thank you for any help.
Got it!
you need to have a default ruby assigned at root level, the other ones you'll set in sites-enabled
configuration files. For example, in my apache2.conf
file:
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.19 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby
then in /etc/apache2/sites-enabled/mysite
that fires up the app that should work in ruby-1.9.3
I'll add PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
:
<VirtualHost xxx.xx.xx.xx:80> PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby ServerName mysite.md DocumentRoot /home/apps/myapp/public <Directory /home/apps/myapp> AllowOverride None Options -MultiViews </Directory> </VirtualHost>
for the app that works with ruby-2.0
no need to add PassengerRuby
option as ruby-2.0
is the default one now.
Also if you have other rvm passenger modules loaded in apache2.config file, like in my case I had:
# LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.18/ext/apache2/mod_passenger.so # PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.18 # PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
you'll need to remove them or comment them as I did, as you'll load the ruby version in /etc/apache2/sites-enabled/mysite
config file.
note!
This will only work on passenger > 4.0.0. I have tested this on passenger-3.0.8 and it does not work. Note that PassengerDefaultRuby was introduced in passenger version 4.0.0, see modrails.com/documentation/….