I've seen other similar questions but none with satisfactory answers, so here goes. I've installed Ruby, Rails, Nginx and Passenger and tried to configure it to all work together.
Here is the relevant part of /opt/nginx/conf/nginx.conf
server {
listen 80;
server_name .myapp.dev; # There is an entry in my local /etc/hosts file for this
passenger_enabled on;
root /srv/www/myapp.dev/public;
access_log /srv/www/myapp.dev/logs/access_log;
error_log /srv/www/myapp.dev/logs/error_log warn;
}
There is another server
block but that's listening for localhost
so I don't think it's causing any issues.
Here is the output of ls -la /srv/www/myapp.dev/
drwxr-xr-x 3 josh josh 4096 Dec 4 19:12 .
drwxr-xr-x 3 josh josh 4096 Dec 4 18:34 ..
drwxr-xr-x 2 josh josh 4096 Dec 4 18:34 logs
lrwxrwxrwx 1 josh josh 37 Dec 4 19:12 public -> /home/josh/rails/myapp/public
I wonder if possibly there's a permissions error, but I don't see any error indicating that it's even attempting to run the Ruby.
This is what gets added to /opt/nginx/logs/error.log
when nginx is restarted
[ 2013-12-04 20:16:17.9953 2321/b6fea000 agents/Watchdog/Main.cpp:574 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/home/josh/.rvm/wrappers/ruby-2.0.0-p353/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_instances_per_app' => '0', 'max_pool_size' => '6', 'passenger_root' => '/home/josh/.rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.26', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.26', 'web_server_pid' => '2320', 'web_server_type' => 'nginx', 'web_server_worker_gid' => '65534', 'web_server_worker_uid' => '65534' }
[ 2013-12-04 20:16:18.0527 2324/b6f0b000 agents/HelperAgent/Main.cpp:626 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.2320/generation-0/request
[ 2013-12-04 20:16:18.1577 2329/b6683000 agents/LoggingAgent/Main.cpp:318 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.2320/generation-0/logging
[ 2013-12-04 20:16:18.1644 2321/b6fea000 agents/Watchdog/Main.cpp:761 ]: All Phusion Passenger agents started!
Nginx serves static files, for example if I visit myapp.dev/500.html then I see the default Rails 500 error page. Phusion Passenger is mentioned in the logs so it seems to be working (even though it is the error.log
, the outcome doesn't seem negative).
I'm tearing my hair out trying to get this to work. Anyone got any ideas?
EDIT
Here is the output of rake routes
rake routes
Prefix Verb URI Pattern Controller#Action
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
root GET / posts#index
But visiting myapp.dev/posts
returns 404
.