I've installed passanger to run as apache module, I installed passenger with gem install passenger as my user ruby in a rvm gemset while running ruby 2.1.2.
On apache this is my main configuration for passenger:
LoadModule passenger_module /home/ruby/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/ruby/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
PassengerDefaultRuby /home/ruby/.rvm/gems/ruby-2.1.2/wrappers/ruby
PassengerResolveSymlinksInDocumentRoot on
</IfModule>
My project uses a different ruby version and I want to use it, so on my virtualhost I'm setting PassengerRuby
PassengerRuby /home/ruby/.rvm/gems/ruby-2.2.1#estas/wrappers/ruby
It exists, and I can use that ruby#gemset to launch for example rails console.
But when I go to the url it raises an error complaining about missing gems.
Could not find rake-10.4.2 in any of the sources (Bundler::GemNotFound)
/home/ruby/.rvm/gems/ruby-2.1.2/gems/bundler-1.7.2/lib/bundler/spec_set.rb:92:in `block in materialize'
....
Ruby interpreter command
/home/ruby/.rvm/gems/ruby-2.1.2/wrappers/ruby
Environment variables
rvm_bin_path = /home/ruby/.rvm/bin
GEM_HOME = /home/otheruser/deploy/shared/bundle/ruby/2.1.0
SHELL = /bin/bash
IRBRC = /home/ruby/.rvm/rubies/ruby-2.1.2/.irbrc
PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXXU7p7Dp
MY_RUBY_HOME = /home/ruby/.rvm/rubies/ruby-2.1.2
PATH = /home/ruby/.rvm/gems/ruby-2.1.2/bin:/home/ruby/.rvm/gems/ruby-2.1.2#global/bin:/home/ruby/.rvm/rubies/ruby-2.1.2/bin:/home/ruby/.rvm/gems/ruby-2.2.1#myproject/bin:/home/ruby/.rvm/gems/ruby-2.2.1#global/bin:/home/ruby/.rvm/rubies/ruby-2.2.1/bin:/home/ruby/.rvm/bin:/usr/local/jdk/bin:/home/otheruser/perl5/bin:/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/usr/local/bin:/usr/X11R6/bin:/home/otheruser/bin
Im curious about the PATH, why does it has both ruby-2.1.2 and ruby-2.2.1? when running passenger, what sets this PATH?
What I'm doing wrongly or why this is not working? I'm doing this project to learn about capistrano and passenger, any help will be greatly appreciated.
Related
I'm having a problem with deploying my rails app on my server. I'm deploying using Passenger for serving up pages. The following error is listed on my page when I start the server. It seems like the version of passenger I have installed is referencing ruby 1.8.7 but my app has been built in 2.0.0. I've tried removing ruby 1.8.7 and reinstalling Passenger, but no luck so far. If I run ruby -v from my directory it lists the version as 2.0.0.
Your Ruby version is 1.8.7, but your Gemfile specified 2.0.0 (Bundler::RubyVersionMismatch)
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.4/lib/bundler/definition.rb:361:in ` validate_ruby!'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.4/lib/bundler.rb:116:in `setup'
/home/ubuntu/.rvm/gems/ruby-2.0.0-p0#global/gems/bundler-1.3.4/lib/bundler/setup.rb:17
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `require'
/var/lib/gems/1.8/gems/passenger- 4.0.0.rc4/lib/phusion_passenger/loader_shared_helpers.rb:212:in `run_load_path_setup_code'
/var/lib/gems/1.8/gems/passenger-4.0.0.rc4/helper-scripts/rack-preloader.rb:73:in `preload_app'
/var/lib/gems/1.8/gems/passenger-4.0.0.rc4/helper-scripts/rack-preloader.rb:127
My apache2.conf file has the following additions:
Include sites-enabled/
<ifmodule mod_ssl.c>
NameVirtualHost *:443
</ifmodule>
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger 4.0.0.rc4/libout/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-4.0.0.rc4
PassengerRuby /usr/bin/ruby1.8
Edit: ANSWER
I was using sudo to install passenger and apache2 module. Should have just typed:
gem install passenger -pre
passenger-install-apache2-module
WITHOUT sudo.
your passenger config is pointing to ruby 1.8
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger 4.0.0.rc4/libout/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-4.0.0.rc4
PassengerRuby /usr/bin/ruby1.8
It should probably look something like this...
LoadModule passenger_module /var/lib/gems/2.0.0/gems/passenger 4.0.0.rc4/libout/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/2.0.0/gems/passenger-4.0.0.rc4
PassengerRuby /usr/bin/ruby2.0.0
Passenger installation is very helpful and it prints these lines for you on the console after successful installation. You should just copy those lines and paste them into your apache conf
You should try install passenger again.
This is why I switched from using RVM to RBENV. You won't run into this problem with RBENV. Plus its just better.
If you upgrade ruby using RVM on your production server, you'll be forced to reinstall passenger/nginx (in your case it looks like just passenger).
Huge pain, and causes server downtime.
Use RBENV instead to save yourself this headache. With RBENV/Capistrano, upgrading can simply be done via your gemfile, and the rest just works.
I tried changing the default ruby command to 1.9.2 but Passenger keeps running 1.8.7
Is Passenger compiled with Ruby embedded?
To set the Ruby version add this line to your vhost file:
PassengerRuby /path/to/the/ruby/version/you/want/to/use
Whenever a "bundle update" updates the version of the passenger gem, I do
sudo su -
passenger-install-apache2-module
At the end of that process, it spits out the full blob of stuff that you need to put at the top or your Apache config. E.g. something like:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p180#rails31/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p180#rails31/gems/passenger-3.0.9
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.2-p180#rails31/ruby
I update the blob of stuff, restart Apache and all seems well.
I imagine that this same process is necessary after updating Ruby.
Set PassengerRuby before the <Directory> tag.
Example:
PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-2.3.1/ruby
It is working for me!
Find more detail in this post.
I'm trying to setup a ruby on rails server on ubuntu10.10 with apache2 and mod_rails (Phusion Passenger).
I already installed ruby 1.9.2-p0 and rails 3.0.8 and installed Passenger with the passenger-install-apache2-module and the passenger gem (v3.0.7).
It then tells me to add 3 lines to my Apache config file. So I added these lines to '/etc/apache2/apache2.conf':
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby
And I edited my '/etc/apache2/httpd.conf' and added:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 192.168.0.2
DocumentRoot /var/www/webop/public
<Directory /var/www/webop/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
I also found out that the file mod_passenger.so in /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/ actually does not exist, its name is mod_passenger.c. But I don't get any errors from that.
The server should only be accessible through a LAN. When I access the server I see all the files and directories in the public folder of my app but the app itself does not get started.
When I restart apache it tells me that mod_rails is already loaded so I guess that passenger is running but I can't figure out why it doesn't start my app!
Thanks in advance!
The reason mod_passenger.so does not exist is because you haven't installed the Apache module. Execute:
passenger-install-apache2-module
This will create the mod_passenger.so file inside your gem directory, and give you three lines to copy into your apache2.conf file.
The passenger module is installed in your current gemset so you shouldn't get any conflicts between projects. You can use any compatible version of Ruby, and any gemset you like, via RVM, and possibly also RBENV. This makes for a nice easy upgrade path from one version of Ruby to the next.
I finally figured out what the problem was: I messed up my ruby installation.
In /usr/local/ I had ruby1.9.2-p0 installed (which was the version I wanted to use) but in /usr/ i had ruby1.8.7 installed.
Passenger was confused which ruby version to use so I changed the LoadModule, PassengerRoot and PassengerRuby paths within apache2/mods-enabled/passenger.load and .config to the correct paths and it finally worked! Both files were created automatically which also caused the problem of a redefinition: On apache startup there was a warning 'mod_passenger already loaded'. So I removed
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/gems/1.9.1/gems/passenger-3.0.7
PassengerRuby /usr/local/bin/ruby
from the apache config and the warning disappeared!
Probably this will help someone else some day!
I have come across a cleaner solution today. This might help future users. The command -
passenger-install-apache2-module
tells me to put these three lines in apache configuration file.
LoadModule passenger_module /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/anwar/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.59
PassengerDefaultRuby /home/anwar/.rvm/gems/ruby-2.2.0/wrappers/ruby
</IfModule>
But, where is that configuration file? The answer is the configuration files are seperated into many pieces and they reside in /etc/apache2/mods-available.
So you should do three things -
Create a file ending with .load in /etc/apache2/mods-available folder. I used passenger.load.
Paste the three lines in that file and save the file.
Now in terminal use sudo a2enmod <module-conf-filename> to enable the module. In my case, the file was, passenger.load. So, I used
sudo a2enmod passenger
Now, restart the server and use the command apache2ctl -M to find that passenger module is enabled.
I think they want you to put those three lines in your httpd.conf file, not in your apache2.conf. At least that's how I've always done it.
I'm trying to deploy a Rails app on an Apache2 server by using Phusion Passenger. While everything works well locally, I am getting the infamous "Bundler::GemNotFound" error while deploying:
Could not find abstract-1.0.0 in any of the sources (Bundler::GemNotFound)
All my gems are installed in my local home folder. Thus the passenger configuration lines from my Apache2 configuration file are as follows:
LoadModule passenger_module /home/regis/.gem/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /home/regis/.gem/gems/passenger-3.0.7
PassengerRuby /usr/bin/ruby1.8
I understand you would need more information to analyse the issue at hand, but I have no idea on how to diagnose this further.
Try doing bundle install --path vendor/cache
I've installed Apache2 and it runs okay.
And I've installed rvm following this link.
After that, I've execute follow commands as its order. Actually some of these commands are from this link installing redmine.
rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=2.3.5
gem install postgres-pr pq
gem install i18n -v=0.4.2
gem install passenger
passenger-install-apache2-module
and append this to apache2.conf
LoadModule passenger_module /home/myhome/.rvm/gems/ruby-1.8.7-p330/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRoot /home/myhome/.rvm/gems/ruby-1.8.7-p330/gems/passenger-3.0.2
PassengerRuby /home/myhome/.rvm/wrappers/ruby-1.8.7-p330/ruby
This is log for Apache after restart
[notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.3 with Suhosin-Patch Phusion_Passenger/3.0.2 configured -- resuming normal operations
But!!!, if I open my redmine root page, it just shows file list in public directory. I think Passenger may not work correctly.
Why? and how to fix this? I've tried everything what I can do for 2 days T-T
Have you added this section to apache config? It tells apache that you are using Rails application:
<VirtualHost :*80>
ServerName myapp
DocumentRoot /root-to-your-path/public
</VirtualHost>
And restarted Apache? Read more here: http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_ruby_on_rails_application
You should view the Passenger Integration guide from RVM, or the more detailed guide from Phusion (the makers of Passenger).
Note that in Phusion's guide, you should omit the --pre when installing the gem, as the guide was written when Passenger 3 was still in beta.