I have a Rails application which is working well on my local machine with Webrick. I trying to deploy it to AWS EC2. I've copied the source of my application from bitbucket to /home/ubuntu
and installed nginx and passenger (and everything else needed like gems, ruby, etc) by this command:
rvmsudo passenger-install-nginx-module
Then I did this:
$ git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
$ sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
$ sudo chown root:root /etc/init.d/nginx
Nginx itself is working well(!), for instance:
$ sudo /etc/init.d/nginx restart
* Stopping Nginx Server... [ OK ]
* Starting Nginx Server...
[ OK ]
It's installed in /opt/nginx, even so I have to use /etc/init.d/nginx to controll its state. Here's my /opt/nginx/nginx.conf file:
server {
listen 80;
server_name localhost;
root /home/ubuntu/my_app/public/;
passenger_enabled on;
}
However, it doesn't display anything but public/index.html
. Anything else is not found. If I remove public/index.html
then it always returns 404.
Of course, it's not what I want. I want it to work as a normal Rails app:
MyApp::Application.routes.draw do
get "about" => "home#about"
get "contacts" => "home#contacts"
root to: "public#home" # I have PublicController and action called home
end
not like a web site with one static web page.
$ ls /opt/nginx/logs
access.log error.log nginx.pid
$ cat error.log
[ 2014-09-15 06:28:30.4247 18366/7f9bb38ab780 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
App 1395 stdout:
App 1395 stderr: DEPRECATION WARNING: Support for Rails < 3.2.13 will be dropped from Formtastic 3.0. (called from require at /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76)
App 18402 stdout:
App 18402 stderr: DEPRECATION WARNING: Support for Rails < 3.2.13 will be dropped from Formtastic 3.0. (called from require at /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76)
App 18402 stderr:
App 18402 stderr: [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
App 18402 stderr:
[ 2014-09-15 06:28:49.3217 18369/7f3cc4259700 Pool2/SmartSpawner.h:298 ]: Preloader for /home/ubuntu/my_app started on PID 18402, listening on unix:/tmp/passenger.1.0.18365/generation-0/backends/preloader.11znc5q
App 19153 stdout:
App 18402 stderr: [DEPRECATED] The 'safe' write concern option has been deprecated in favor of 'w'.
App 18402 stderr:
App 18402 stderr: cache: [GET /456] miss
App 18402 stderr: cache: [GET /public/home] miss
App 18402 stderr: WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
App 18402 stderr:
App 18402 stderr: cache: [GET /] miss
and
App 1395 stderr:
App 1395 stderr: cache: [GET /] miss
App 1395 stderr: cache: [GET /home/index] miss
App 1395 stderr: cache: [GET /public/home] miss
App 1395 stderr: cache: [GET /fdsfd] miss
App 1395 stderr: cache: [GET /public] miss
App 1395 stderr: cache: [GET /public/home] miss
App 1395 stderr: cache: [GET /public/hoe] miss
App 1395 stderr: cache: [GET /manager/html] miss
App 1395 stderr: cache: [GET /clientaccesspolicy.xml] miss
App 1395 stderr: cache: [GET /hello.html] miss
What did I do wrong?