Zero
Zero

Reputation: 151

Apache-Passenger can't start my production rails application

I'm new to deploying rails applications and for what I read in many sites the Apache/Passenger combo was one of the simplest ones; however I have encountered that Passenger does not want to start my application and displays the following error message when entering the sudo tail -50 /var/log/apache2/error.log command:

Could not spawn process for application /home/test/Documents/sites/depot:
An error occured while starting up the preloader.
Message from application: cannot load such file -- bundler/setup (LoadError)
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:406:in
`activate_gem'
...
age/Cor/Req/CheckoutSession.cpp:252 ]: [Client 1-1] Cannot checkout session
because a spawning error occurred. The identifier of the error is 6ce15bbe.
Please see earlier logs for details about the error.

I suspect it has to do with my ruby installation, I used rbenv and got the 2.2.3 version but in the error message it was linking to a 2.0.0 version which I have never installed. I also suspect that it has something to do with me using this two commands from another guide:

 sudo rm /usr/bin/ruby
 sudo ln -s /usr/local/bin/ruby /usr/bin/ruby

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04

If anybody know how to fix this headache of a problem I'll really appreciate it.

Thanks!

Upvotes: 3

Views: 2214

Answers (2)

Zero
Zero

Reputation: 151

After some clues left by @dimakura and @CamdenNarzt I was able to solve this in two stages.

  1. As I suspected Passenger was using the wrong version of ruby, to fix this I modified the passenger.conf file located under /etc/apache2/mods-available/ with the output of the which ruby command:

Added the line (replace with your own which ruby output)

PassengerRuby /home/test/.rbenv/shims/ruby
  1. Restarted apache got a "Incomplete response received from application" error message, checked the logs and noticed that the proper version of ruby was now being used but got an error message:

    "Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml"

Installed the Figaro gem by following the instructions on this site: https://www.twilio.com/blog/2015/02/managing-development-environment-variables-across-multiple-ruby-applications.html then generated a secret key using the command:

rake secret

Copied the output and opened the config/application.yml file where I entered:

SECRET_KEY_BASE: [output key from rake secret command]

Restarted Apache and it worked!!

Upvotes: 1

dimakura
dimakura

Reputation: 7655

You probably need to specify correct PassengerDefaultRuby in your httpd.conf file.

My recommendation is to go through the installation of passenger using their official guide:

https://www.phusionpassenger.com/library/install/apache/

Upvotes: 1

Related Questions