【问题标题】:Unable to start passenger watchdog but passenger installed无法启动乘客看门狗,但已安装乘客
【发布时间】:2014-07-08 08:46:33
【问题描述】:

我想在 ubuntu 12.04 VM (vagrant box) 上设置带有乘客支持的 nginx。因此,我创建了以下厨师食谱 (https://github.com/i42n/wrapper-nginx-passenger/blob/master/recipes/default.rb):

#
# Cookbook Name:: wrapper-nginx-passenger
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute

apt_repository 'nginx-passenger' do
  uri          'https://oss-binaries.phusionpassenger.com/apt/passenger'
  distribution node['lsb']['codename']
  components   ['main']
  keyserver    'keyserver.ubuntu.com'
  key          '561F9B9CAC40B2F7'
end

# install nginx which contains passenger support
package "nginx-extras"
package "passenger"

# define nginx service as the nginx::passenger recipe restarts the service
# and fails if the service does not exist
service 'nginx' do
  supports :status => true, :restart => true, :reload => true
  action   :start
end

# installs the passenger gem
include_recipe "nginx::passenger"

# create server config template in nginx config directory
template "/etc/nginx/sites-available/plantasy" do
  source "plantasy.erb"
  mode 0644
  owner "root"
  group "root"
end

# symlink the config to the active sites directory
link "/etc/nginx/sites-enabled/plantasy" do
  to "/etc/nginx/sites-available/plantasy"
end

它从这里遵循乘客安装指南:https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#install_add_apt_repo

但是,如果我尝试启动 nginx,我会收到以下错误:

vagrant@vagrant:/etc/nginx/conf.d$ sudo service nginx restart
 * Restarting nginx nginx
nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable (/usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45/buildout/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable. (-1: Unknown error)
   ...done.

如果 nginx 没有在乘客支持下正确编译,这实际上似乎是一个常见错误。但是,如果我检查 nginx 模块,我的 nginx 确实有乘客支持:

vagrant@vagrant:~$ nginx -V
nginx version: nginx/1.6.0
TLS SNI support enabled
configure arguments: --with-cc-opt= --with-ld-opt= --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_spdy_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/headers-more-nginx-module --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-auth-pam --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-cache-purge --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-dav-ext-module --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-development-kit --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-echo --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/ngx-fancyindex --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-http-push --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-lua --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-upload-progress --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/nginx-upstream-fair --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/ngx_http_substitutions_filter_module --add-module=/tmp/buildd/nginx-1.6.0/debian/modules/passenger/ext/nginx

这个错误实际上是正确的。乘客在 nginx 启动时寻找的文件/文件夹不存在:

vagrant@vagrant:/etc/nginx/conf.d$ ls -l /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45
total 196
-rw-r--r--  1 vagrant root 80232 Jul  7 13:38 CHANGELOG
-rw-r--r--  1 vagrant root 15919 Jul  7 13:38 CONTRIBUTING.md
-rw-r--r--  1 vagrant root  1035 Jul  7 13:38 CONTRIBUTORS
-rw-r--r--  1 vagrant root   363 Jul  7 13:38 INSTALL.md
-rw-r--r--  1 vagrant root  1056 Jul  7 13:38 LICENSE
-rw-r--r--  1 vagrant root  2880 Jul  7 13:38 README.md
-rw-r--r--  1 vagrant root  1814 Jul  7 13:38 Rakefile
-rw-r--r--  1 vagrant root  2345 Jul  7 13:38 Vagrantfile
drwxr-xr-x  2 vagrant root  4096 Jul  7 13:38 bin
drwxr-xr-x  2 vagrant root  4096 Jul  7 13:38 build
-rwxr-xr-x  1 vagrant root   287 Jul  7 13:38 configure
drwxr-xr-x  4 vagrant root  4096 Jul  7 13:38 debian.template
drwxr-xr-x  4 vagrant root  4096 Jul  7 13:38 dev
drwxr-xr-x  5 vagrant root  4096 Jul  7 13:38 doc
drwxr-xr-x  2 vagrant root  4096 Jul  7 13:38 download_cache
drwxr-xr-x 10 vagrant root  4096 Jul  7 13:38 ext
drwxr-xr-x  3 vagrant root  4096 Jul  7 13:38 helper-scripts
drwxr-xr-x  3 vagrant root  4096 Jul  7 13:38 lib
drwxr-xr-x  2 vagrant root  4096 Jul  7 13:38 man
drwxr-xr-x  3 vagrant root  4096 Jul  7 13:38 node_lib
-rw-r--r--  1 vagrant root  6514 Jul  7 13:38 npm-shrinkwrap.json
-rw-r--r--  1 vagrant root   722 Jul  7 13:38 package.json
-rw-r--r--  1 vagrant root  1243 Jul  7 13:38 passenger.gemspec
drwxr-xr-x  4 vagrant root  4096 Jul  7 13:38 resources
drwxr-xr-x  2 vagrant root  4096 Jul  7 13:38 rpm
drwxr-xr-x 10 vagrant root  4096 Jul  7 13:38 test

我有一个默认的nginx.conf/etc/nginx/conf.d/passenger.conf 看起来像这样:

vagrant@vagrant:/etc/nginx/conf.d$ cat /etc/nginx/conf.d/passenger.conf 
passenger_root /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.45;
passenger_ruby /usr/local/rvm/rubies/ruby-2.1.2/bin/ruby;
passenger_max_pool_size 6;
passenger_spawn_method smart-lv2;
passenger_buffer_response on;
passenger_min_instances 1;
passenger_max_instances_per_app 0;
passenger_pool_idle_time 300;
passenger_max_requests 0;

如果我删除 passenger.conf nginx 启动时没有错误,并且可以正常提供默认测试页面。正如预期的乘客不工作。

我的乘客应用 nginx 配置如下所示:

vagrant@vagrant:~$ cat /etc/nginx/sites-enabled/plantasy 
# Only for development purposes.
# For production environment, set it accordingly (i.e. production)
# Remove this line when you upload an actual application.
# For * TESTING * purposes only.
passenger_app_env development;

server {
  listen 8080;
  server_name example.com;
  passenger_enabled on;
  passenger_ruby /usr/local/rvm/rubies/ruby-2.1.2/bin/ruby;
  root /home/vagrant/app/public;
}

如果我尝试访问此页面,我会收到 403:

vagrant@vagrant:~$ curl localhost:8080
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.6.0</center>
</body>
</html>

Ruby 安装正确:

vagrant@vagrant:~$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

还安装了乘客 gem。

vagrant@vagrant:~$ gem list passenger

*** LOCAL GEMS ***

passenger (4.0.45)

我真的不知道怎么了。我查看了this thread,但正如您在上面看到的,我有 nginx 并提供乘客支持。只是缺少乘客二进制文件?

任何想法如何解决这个问题?

在任何人建议之前:我不想自己编译 nginx。我想使用 apt 存储库中的版本,因为它极大地提高了 vagrant VM 设置的性能。

【问题讨论】:

    标签: ruby-on-rails nginx passenger vagrant chef-infra


    【解决方案1】:

    您的乘客根指令不正确。您可以按照此处的指南找到它的正确值: https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#inserting_passenger_root_for_apt

    【讨论】:

    • 对于我们这些使用RubyGems的人来说,命令是passenger-config --root
    【解决方案2】:

    检查passenger-install-nginx-module是否正确安装。

    'which passenger-install-nginx-module'

    如果未安装,请尝试:

    rvmsudo passenger-install-nginx-module
    

    这适用于 rvm 用户。会解决问题

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 2012-03-14
      • 2018-05-16
      • 2018-03-13
      • 1970-01-01
      • 2012-07-10
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多