Ruby 2.0.0 Rails 4.0.0 Nginx Passenger on Ubuntu 12.04
This question has been asked too many times. I've spent hours going through all the posts on stackoverflow and so far no luck. Always get 403 Forbidden when trying to access my rails app. Testing this with an empty newly generated app.
All files in /var/www are owned by www-data. I've set permissions to 755 on the full path to the code. When I add index.html to the public directory it gets displayed, but I can't get the app to run.
Here is the configuration in sites enabled
server {
listen 80;
root /var/www/default/public;
server_name s.dev
passenger_enabled on;
rails_env development;
}
nginx.conf
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_vary off;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/rss+xml application/atom+xml text/javascript application/javascript application/json text/mathml;
gzip_min_length 1000;
gzip_disable "MSIE [1-6].";
server_names_hash_bucket_size 64;
types_hash_max_size 2048;
types_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
passenger.conf
passenger_root /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17;
passenger_ruby /usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby;
passenger_max_pool_size 6;
passenger_spawn_method smart-lv2;
passenger_use_global_queue on;
passenger_buffer_response on;
passenger_min_instances 1;
passenger_max_instances_per_app 0;
passenger_pool_idle_time 300;
passenger_max_requests 0;
Any suggestions as to what I can try will be much appreciated!
Thank you
More information:
passenger-config --root
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17
which ruby
/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby
This is the error
2013/09/11 16:03:00 [error] 30400#0: *3 directory index of "/var/www/default/public/" is forbidden, client: 145.33.44.33, server: s.dev, request: "GET / HTTP/1.1", host: "s.dev"
passenger-memory-stats
Version: 4.0.17
Date : 2013-09-11 16:24:16 -0400
------- Apache processes --------
### Processes: 0
### Total private dirty RSS: 0.00 MB
---------- Nginx processes ----------
PID PPID VMSize Private Name
-------------------------------------
32226 1 38.8 MB 0.2 MB nginx: master process /opt/nginx-1.5.4/sbin/nginx
32227 32226 39.2 MB 0.6 MB nginx: worker process
32228 32226 39.2 MB 0.5 MB nginx: worker process
### Processes: 3
### Total private dirty RSS: 1.25 MB
----- Passenger processes -----
PID VMSize Private Name
-------------------------------
32200 216.2 MB 0.3 MB PassengerWatchdog
32205 489.6 MB 0.3 MB PassengerHelperAgent
32220 223.6 MB 0.8 MB PassengerLoggingAgent
### Processes: 3
### Total private dirty RSS: 1.40 MB
I am also able to run app successfully when running "passenger start"
So it started to work. The weird part is that I can't really tell what caused it to start working. I've made a few mistakes along the way that I have fixed. One was adding basic auth incorrectly to the site configuration:
server {
listen 80;
root /var/www/default/public;
server_name s.dev;
location / {
auth_basic "Restricted";
auth_basic_user_file /var/www/default/.htpasswd;
passenger_enabled on; <------ did not remember to add this
}
passenger_enabled on;
rails_env development;
}
Another thing was to add a user to nginx.conf and make this user the owner of /var/www/default - although I am pretty sure that this was one of the things I've tried when things were not working
Thank you everyone for helping out
maybe it is because of the passenger_spawn_method smart-lv2
? according to http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_passenger_max_instances_per_app_lt_integer_gt :
As of Phusion Passenger 4.0, conservative spawning was renamed to direct and smart-lv2 was renamed to smart. The old smart spawning has been removed in favor of the new version.
And as:
The default value is smart.
try just removing it.
链接地址: http://www.djcxy.com/p/32406.html上一篇: 搭乘铁轨的nginx红宝石找不到意见