Rails app doesn't run on AWS Elastic Beanstalk, sqlite3 error - ruby-on-rails

I have been trying to get started running Rails on AWS' Elastic Beanstalk, but I have run in to a seemingly insurmountable obstacle: While I am able to spin up a new Elastic Beanstalk running the sample application, I cannot seem to get an EB instance to successfully run my own code.
Here are the steps I have taken:
Locally running ruby 1.9.3p545 on OSX 10.9.3
Installed aws-eb client tools.
Scrupulously followed the following tutorial from Amazon: Deploying a Rails Application to AWS Elastic Beanstalk (tl;dnr: use 'rails new' to create a new rails app, commit to git and then use 'eb init' to create an EB instance of the type '64bit Amazon Linux 2014.03 v1.0.3 running Ruby 1.9.3' and then running 'eb start')
After waiting a seeming eternity for the EB instance to be created, I navigate to the url Amazon provides.
Instead of seeing my rails app (which, by the way, runs fine locally), I get the dreaded "We're sorry, but something went wrong" page:
I have tried these steps multiple times, with the same results. I have tried using different environments (the Ruby 2.0.0 Puma and Passenger ones, for instance, updating my ruby via rvm as necessary).
Before this is flagged as a duplicate, let me state straight away that I have looked at the following questions and found that they have not solved my problem:
AWS Elastic Beanstalk: Launching a new Rails App
Deploying an existing Rails app to AWS Elastic Beanstalk
Following the advice in the question "AWS Elastic Beanstalk: Launching a new Rails App", which seems very similar to my issue, I let the app run over night and I am still getting the error.
I've ssh'd in to the instance. Interestingly, both production.log and development.log appear to be empty (the ones in /var/app/support/logs, anyway). However, I find the following in passenger.log:
********* snip *********
[ 2014-06-12 21:42:38.8400 5133/7fe66aee4700 agents/HelperAgent/RequestHandler.h:2210 ]: [Client 20] Cannot checkout session.
Error page:
cannot load such file -- sqlite3/sqlite3_native (LoadError)
/usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:6:in require'
/usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:6:inrescue in '
/usr/local/share/gems1.9/gems/sqlite3-1.3.9/lib/sqlite3.rb:2:in <top (required)>'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:inrequire'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in block (2 levels) in require'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:ineach'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in block in require'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:ineach'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in require'
/usr/local/share/gems1.9/gems/bundler-1.6.2/lib/bundler.rb:132:inrequire'
/var/app/current/config/application.rb:7:in <top (required)>'
/var/app/current/config/environment.rb:2:inrequire'
/var/app/current/config/environment.rb:2:in <top (required)>'
config.ru:3:inrequire'
config.ru:3:in block in <main>'
/usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:ininstance_eval'
/usr/local/share/gems1.9/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize'
config.ru:1:innew'
config.ru:1:in <main>'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:ineval'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:112:in preload_app'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:158:in'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:29:in <module:PhusionPassenger>'
/usr/local/share/gems1.9/gems/passenger-4.0.41/helper-scripts/rack-preloader.rb:28:in'
App 5241 stdout:
App 5241 stdout:
[ 2014-06-12 21:45:26.2512 5133/7fe66d1ef700 Pool2/Implementation.cpp:883 ]: Could not spawn process for group /var/app/current#default: An error occured while starting up th$
in 'void Passenger::ApplicationPool2::SmartSpawner::handleErrorResponse(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:455)
in 'std::string Passenger::ApplicationPool2::SmartSpawner::negotiatePreloaderStartup(Passenger::ApplicationPool2::SmartSpawner::StartupDetails&)' (SmartSpawner.h:566)
in 'void Passenger::ApplicationPool2::SmartSpawner::startPreloader()' (SmartSpawner.h:206)
in 'virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:752)
in 'void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const Passenger::ApplicationPool2::SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned in$
******** end snip ********
Not sure if sqlite3 is the problem or not, but it does appear to be installed on the instance. Just in case, I installed the sqlite3 gem again.
Here is the output of passenger-status:
Version : 4.0.41
Date : 2014-06-13 13:25:52 +0000
Instance: 5148
----------- General information -----------
Max pool size : 6
Processes : 0
Requests in top-level queue : 0
----------- Application groups -----------
/var/app/current#default:
App root: /var/app/current
Requests in queue: 0
I'm no expert, but it seems like passenger isn't running (processes == 0).
What am I missing? Is there some "JUST_WORK_DARNIT" config that I have neglected to set to true?
If, in fact, there is an issue with the sqlite3 install, as is suggested below, what can I do to resolve the issue?

Can you try installing sqlite-devel by running yum install sqlite-devel?
You may want to use ebextensions to try this out on beanstalk.
Try creating a file with path .ebextensions/00-myfile.config in your app source directory before deploying to beanstalk.
packages:
yum:
sqlite-devel: []
Sounds similar to the problem discussed here Why can't I install the SQLite gem?
Let me know if that works.
Update
There is one thing that changed with Rails 4. Possibly you are hitting this issue.
See the discussion here: https://github.com/rails/rails/pull/8468
The default sample app generated by rails 4 does not work in production mode because of the above change. You can however make it work by modifying the sample app to include a non-default web page.
I tried the following:
After running "rails new appname", "git init", "eb init" try the following steps. (Based on this answer).
Edit config/routes.rb so that it contains root :to => 'proto#index'
Create app/controllers/proto_controller.rb with the following contents
class ProtoController < ApplicationController
def index
end
end
Create file app/views/proto/index.html.erb and write something in that file ... 'Hello World'.
Then launch your environment. That should work.
When I try without following the above three steps then I also get an error page. But with these changes I do not see an error page.
I would recommend you perform the above steps in a fresh directory on a new environment. I tested with the latest Ruby solution stack "64bit Amazon Linux 2014.03 v1.0.4 running Ruby 2.0 (Puma)".
Also at some point when you get to Step 6 on this tutorial, you might end up replacing gem 'sqlite3' with gem 'mysql2' but that is the next step after you get the sample app running.

Yes, the sqlite3 gem is the problem. It is installed, but not correctly installed. A key file (namely the sqlite3_native library file) is missing.

Related

redminex installation, rake redmine:plugins:migrate "Cannot load such file", "load error"

I am setting up a machine running:
ruby 3.0.4-p208
passenger 6.0.14
redmine 5.0.1.stable
redmineUP latest version of all plugins
mysql2 5.7
I'm trying to install redmineX, which theoretically plays well and requires redmineUP. RedmineUP is installed and is more-or-less running. I'm having an error during the install:
bundle exec rake redmine:plugins:migrate RAILS_ENV=redmine_test
fails with the error:
cannot load such file -- redmine_x_ux_upgrade/view_projects_hook (LoadError)
/home/test_user/.gem/ruby/3.0.4/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/home/test_user/.gem/ruby/3.0.4/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
/home/test_user/.gem/ruby/3.0.4/gems/activesupport-6.1.6/lib/active_support/dependencies/zeitwerk_integration.rb:51:in `require_dependency'
/home/test_user/redmine-5.0.1/plugins/000_redmine_x_ux_upgrade/init.rb:22:in `<top (required)>'
/home/test_user/redmine-5.0.1/lib/redmine/plugin_loader.rb:31:in `load'
- GEM PATHS:
- /home/test_user/.gem/ruby/3.0.4
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0
The file in question exists:
/home/test_user/redmine_test/plugins/000_redmine_x_ux_upgrade/lib/redmine_x_ux_upgrade/view_projects_hook.rb
Ideas?
Since this is occurring at the bundle exec rake, rather than in the redmine app, I'm assuming this issue is with the user GEM_PATH. I've tried tweaking GEM_PATH to also contain
/home/test_user/redmine_test/
/home/test_user/redmine_test/plugins/
with no success.
This turned out to be a versioning problem; using plugins written for redmine 4.x in a redmine-5.x environment.
The main problem was the vendor's helpdesk reformatted email so well-formatted plain-text with blank line separated error and log output ended up all run together. After turning all logs, error output, directory listings, etc. into separate files and attaching them, they could read the main part of the mail and identify the problem.

Ruby 2.5.1, Ruby Java Bridge (RJB), and Ubuntu 18.04: Getting `Constants DL and Fiddle is not defined.`

I need help. I can't figure out why I can't boot my Rails 5.2 app now that rjb is a dependency. I keep getting a generic error about Constants DL and Fiddle is not defined.
First, yes I have read the Documentation.
Second, yes I have set JAVA_HOME.
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
Third, I have set LD_LIBRARY_PATH (COULD THIS BE THE PROBLEM?)
$ echo $LD_LIBRARY_PATH
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64
However, whenever I try to open rails console or rails server I just get the error:
$ rails c
/home/daniel/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'fillable-pdf'.
Gem Load Error is: Constants DL and Fiddle is not defined.
Backtrace for gem load error is:
/home/daniel/.rvm/gems/ruby-2.5.1#fuel/gems/fillable-pdf-0.6/lib/fillable-pdf/itext.rb:4:in `load'
....
<redacted>
The app runs fine on OSX, on CircleCI, and on Heroku. Does someone with more experience with rjb than me spot what I'm missing here?
Thank you in advance!
After rebooting and running some updates, it seems to work now. So all of the above appears to be correct. No JVM issues when opening up rails console anymore.

Ruby-on-rails cannot connect to mysql2; Windows 10

I'm on Windows 10 and am a complete beginner programmer. I am using Ruby 2.4.2, Rails 5.1.4 and am following a Lynda course on how to run Rails 5 on Windows.
There's a part near the end where the tutor says to enter:
>rails db:schema:dump
to test whether you've established a connection to the MySQL by create a file inside the created project.
This is what I get when I enter the above command:
C:\Users\notmyactualuser\Documents\Sites\demo_project>rails db:schema:dump
rails aborted!
LoadError: cannot load such file -- mysql2/2.4/mysql2
C:/Users/notmyactualuser/Documents/Sites/demo_project/config/application.rb:7:in `<top (required)>'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `require_relative'
C:/Users/notmyactualuser/Documents/Sites/demo_project/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
The tutor doesn't address what to do with potential errors and I can't seem to find an answer. I want to build a login form using RoR and am trying to grasp the basics (clearly failing). If possible, can I get help with the above and be directed to an easy, simple, "how-to" on building a login form?
Thanks a lot.
P.S. My first post, so please go easy on me, lol.
UPDATE: So I used the command on CMD and it looks like it's successful. Can somebody point me to how to get it working with Rails?
UPDATE 2: I put in the command that Hoa requested and I got this:
ERROR: "bundle install" was called with arguments ["mysql2"]
Usage: "bundle install [OPTIONS]"
UPDATE 3: I did as Satishkakumar said and I got this:
You've installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.1.6.
It's recommended to use the exact same version to avoid potential issues.
At the time of building this gem, the necessary DLL files were retrieved from:
http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.6-win32.zip
This gem includes vendor/libmysql.dll with redistribution notice in vendor/README.
======================================================================================================
Looks like it's all sorted now? Please let me know if there's any more.
I think its issue of installing mysql2 gem in system. Follow below steps to install.
In Gemfile add the line
gem 'mysql2', '0.3.21'
And run bundle install from project folder in CMD.
bundle install mysql2
This might solve your issue. Let me know in comment section if your issue still persists.

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!
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/
After some clues left by #dimakura and #CamdenNarzt I was able to solve this in two stages.
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
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!!

Phusion Passenger with Apache troubleshooting - openSSL load error, link time reference?

I'm past all this now and trying to fix the problem not in quotes down below, but leaving for background information.
I am trying to get a working rails development environment on my LAMP
stack, so I've installed rbenv, the 2.1.2 version of ruby, the 4.1.4
version of Rails and the phusion mod for Apache. I'm now seeing very
strange errors when I try to stop and start my Apache service and I
think the issue is that Phusion has rebuilt the Apache installation on
the machine and Apache is now looking for configuration files in
/etc/apache2/. I'm now struggling to find out how to fix apache to
look in the LAMP directories for httpd.conf.
Here are some examples of the errors.
$ sudo service apache2 restart
* Restarting web server apache2
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
$ sudo /opt/lampp/lampp restart
Restarting XAMPP for Linux 1.8.3-4...
XAMPP: Stopping Apache...fail.
apachectl returned 1.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...not running.
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...fail.
XAMPP: Another FTP daemon is already running.
Also, this is how I've modified the config file in
/opt/lampp/etc/httpd.conf. I know the module is supposed to be a .so
file but I did not see one in my directory (didn't really spend enough
time looking into this to know how to fix it, do I need to compile
something?)
LoadModule passenger_module /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/ext/apache2/mod_passenger.c
PassengerRoot /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45
PassengerRuby /home/moody/.rbenv/versions/2.1.2/bin/ruby
Server is running Ubuntu 14.04. Install order was LAMP (1.8.3-4), Ruby
1.9.3 (via apt-get), then rbenv, then ruby-build, then installed Ruby 2.1.2, then removed Ruby 1.9.3 via apt-get remove, then installed rails gems, then installed phusion for Apache and the ruby gem for
phusion.
Edit 1: I found out it's actually an issue with my LoadModule file
paths
I checked out the actual LAMPP script to see where the apachectl
returned 1 error was coming from and it was just running
/opt/lampp/bin/apachectl, so then I ran the same command
/opt/lampp/bin/apachectl -k stop and it gave me a very descriptive
error:
httpd: Syntax error on line 160 of /opt/lampp/etc/httpd.conf: Cannot load /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/ext/apache2/mod_passenger.c into server: /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/ext/apache2/mod_passenger.c: invalid ELF header
Commented out my lines-need to figure out how to get the appropriate
.so file.
Edit 2:
I ran the passenger-install-apache2-module installer and it seemed to work fine and told me the lines to add to my program (including the .so file which I was missing before)
Now I'm running into a far more confusing error that I think is related to the version of GCC that is available for ubuntu 14.04 and I can't find any resources on the internet that deal with this problem
httpd: Syntax error on line 160 of /opt/lampp/etc/httpd.conf: Cannot load /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/buildout/apache2/mod_passenger.so into server: /opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/buildout/apache2/mod_passenger.so)
Saw this in another google search to see which GCC versions are available, apparently 3.4.9 isn't one of them (go figure, that's what the error says.) Any ideas on how I can remedy this?
$ strings /opt/lampp/lib/libstdc++.so.6 | grep -i glibcxx
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_FORCE_NEW
Edit 3: It's 6 AM and I think I figured it out at last.
I did a few searches and found this post here:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
And then I did a find on the root directory
find / | grep -i libstdc++.so
And used the strings command I found earlier-the libstdc++.so had GLIBCXX_3.4.9 in the directory /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 so I backed up the old one with mv and copied the new one to the lampp directory. Restarted the server and got no errors. Supposedly I have a working rails stack now :)
Edit 4:
Welp, Phusion is working, but there's a new problem... Now when I navigate to my new virtual host (RailsEnv set to development) I get this lovely stack trace on a bunch of code I have no experience with. Seems like something's wrong with the sha1.so referencing some unknown symbol that's supposed to be in libcrypto.so.1.0.0. What the heck is link time reference?
Interestingly, if I just navigate to the application folder and do rails server, I can see the application without issue. Does the application need to be generated? (i.e. call rails generate)?
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-linux/digest/sha1.so: symbol SHA1_Init, version OPENSSL_1.0.0 not defined in file libcrypto.so.1.0.0 with link time reference - /home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/x86_64-linux/digest/sha1.so (LoadError)
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/definition.rb:1:in `<top (required)>'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler.rb:153:in `definition'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler.rb:116:in `setup'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.3/lib/bundler/setup.rb:17:in `<top (required)>'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/lib/phusion_passenger/loader_shared_helpers.rb:258:in `block in run_load_path_setup_code'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/lib/phusion_passenger/loader_shared_helpers.rb:361:in `running_bundler'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/lib/phusion_passenger/loader_shared_helpers.rb:256:in `run_load_path_setup_code'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/helper-scripts/rack-preloader.rb:100:in `preload_app'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/home/moody/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/helper-scripts/rack-preloader.rb:28:in `<main>'
The errors you are getting says that port [:80] is already in use so checking which process has that port occupied and killing that process might be the fix for you. You can do this by running
sudo kill $(sudo lsof -t -i:80)
or
sudo kill sudo lsof -t -i:9001
After the process gets terminated, try restarting the apache server.
I had a very similar error like yours which is regarding the OPENSSL version.
You can refer this post. https://groups.google.com/forum/?hl=en#!topic/phusion-passenger/6nRi0FU98_g
For my case, I resolved it by changing my apache version to 2.2.22

Resources