spacerobot spacerobot - 3 years ago 146
Apache Configuration Question

Rails web application error on start

I am new to linux and rails and am trying to get a development server up and running. I have installed ruby/rails and had it working under localhost:3000. I can create a rails app and have it run.

I then installed apache 2/passenger. When I try to hit the IP address of the machine I am getting the following error:

It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:

bundle install

If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:

Is this app supposed to be run as the a-cjstewar user?
Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.

-------- The exception is as follows: -------

Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:87:in `block in materialize'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:81:in `map!'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/spec_set.rb:81:in `materialize'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:159:in `specs'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:218:in `specs_for'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/definition.rb:207:in `requested_specs'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:109:in `block in definition_method'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:21:in `setup'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler.rb:101:in `setup'
/var/lib/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/setup.rb:19:in `<top (required)>'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'


Here is my app1.conf file:

<VirtualHost *:80>
ServerName 122.112.8.102
ServerAdmin user@email.com
DocumentRoot /home/username/app1/public
RailsEnv development
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/username/app1/public">
Require all granted
Options FollowSymLinks
# This relaxes Apache security settings.
AllowOverride None
# MultiViews must be turned off.
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


ruby -v

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]


rails -v

Rails 5.1.2


apache2 -v

Server version: Apache/2.4.18 (Ubuntu)


passenger -v

Phusion Passenger 5.1.6


I'm not sure where to go from here. Any help is appreciated!

Answer Source

It appears that you are running your application with a different Ruby than you think you are.

In order to get the Ruby 2.4.0p0 that you say your app should be running on, you should find out where that Ruby is located with

which ruby

Then, you can set that executable as the Ruby you want to use by using the PassengerRuby directive in your <VirtualHost>:

<VirtualHost *:80>
    PassengerRuby: /path/to/ruby
    # other stuff
</VirtualHost>

Check out the documentation for the PassengerRuby directive to learn more.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download