我见过其他类似的问题,但没有一个能给出令人满意的答案,所以就在这里。我已经安装了 Ruby、Rails、Nginx 和 Passenger,并尝试将它们配置为协同工作。
以下是相关部分/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;
}
还有另一个server
块,但它正在监听,localhost
所以我不认为它会引起任何问题。
以下是输出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
我想知道是否可能存在权限错误,但我没有看到任何错误表明它甚至试图运行 Ruby。
/opt/nginx/logs/error.log
这是在 nginx 重新启动时添加的内容
[ 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 提供静态文件服务,例如,如果我访问 myapp.dev/500.html,则会看到默认的 Rails 500 错误页面。日志中提到了 Phusion Passenger,因此它似乎正在运行(尽管它是error.log
,但结果似乎并不负面)。
我正绞尽脑汁想让它发挥作用。有人有什么想法吗?
编辑
以下是输出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
但回访myapp.dev/posts
仍会继续404
。
答案1
乘客找不到您的申请....
变成root /srv/www/myapp.dev/public;
root /home/josh/rails/myapp/public;