Elastic Beanstalk with Passenger Standalone: working configuration


I'm trying to migrate an elastic beanstalk app from Puma to Phusion Passenger. However, Passenger fails at startup with the error:

  /opt/elasticbeanstalk/support/conf/nginx_config.erb:48:in `block in write_nginx_config_file': undefined local variable or method `location_config_filename' for #<PhusionPassenger::Standalone::StartCommand:0x007f1eb35d06f0> (NameError)
    from /opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/erb.rb:863:in `eval'
    from /opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/erb.rb:863:in `result'
    from /opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/passenger-5.0.15/lib/phusion_passenger/standalone/start_command/nginx_engine.rb:120:in `block in write_nginx_config_file'

The Amazon stack name is:

64bit Amazon Linux 2015.03 v2.0.0 running Ruby 2.2 (Passenger Standalone)

The same app runs locally and on Heroku using Passenger. (It also runs OK with Puma).

Is there a required configuration file or configuration option I've missed?

(I'm using eb_deployer for blue-green deployment rather than the AWS Console – so it might be a default somewhere).

Best Answer

I was having the same issue and after some digging I found that the version of passenger Amazon was using on

64bit Amazon Linux 2015.03 v2.0.0

is Passenger 4.0.59.

If you just have gem "passenger" in your gemfile without specifying the version your app is installing v5.0 or newer which conflicts with the EBS setup. Whatever changes they made between 4.0.59 and 5.0 seems to be messing up the deploy because when I set the version in my gemfile and redeployed it worked.

gem "passenger", '~> 4.0.59'

After you update your gemfile and push the code make sure you terminate the instance to get a fresh one. After the deploy check the eb-activity.log for the line

Using passenger 4.0.59

EDIT: As Chris pointed out below you don't need to include passenger in your gem file since it is already included. This will prevent the issue all together, no need to worry about versions.

gem "passenger ", group: :development
Related Topic