这个问题已被问过太多次了。我花了几个小时浏览stackoverflow上的所有帖子,到目前为止没有运气。尝试访问我的rails应用程序时始终获得403 Forbidden。使用新生成的空应用程序对此进行测试。
/ var / www中的所有文件都归www-data所有。我已经在代码的完整路径上将权限设置为755。当我将index.html添加到公共目录时,它会显示,但我无法让应用程序运行。
以下是启用网站的配置
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;
对于我可以尝试的任何建议都将不胜感激!
谢谢
更多信息:
passenger-config --root
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17
哪个红宝石
/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby
这是错误
2013/09/11 16:03:00 [错误] 30400#0:* 3目录索引“/ var / www / default / public /”被禁止,客户端:145.33.44.33,server:s.dev ,请求:“GET / HTTP / 1.1”,主持人:“s.dev”
乘客存储器统计
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
我也可以在运行“乘客开始”时成功运行应用程序
答案 0 :(得分:2)
所以它开始起作用了。奇怪的是,我无法确定是什么导致它开始工作。在我修复过的路上,我犯了一些错误。一种是将错误的基本身份验证添加到站点配置中:
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;
}
另一件事是将用户添加到nginx.conf并使该用户成为/ var / www / default的所有者 - 尽管我很确定这是我在事情不能工作时尝试过的事情之一< / p>
谢谢大家帮忙
答案 1 :(得分:0)
也许是因为passenger_spawn_method smart-lv2
?
根据{{3}}:
从Phusion Passenger 4.0开始,保守的产卵被重命名为直接产品并且智能化lv2被重命名为智能产品。旧的智能产卵已被删除,有利于新版本。
以及:
默认值为智能。
尝试删除它。