RVM + Nginx +厨师长 [英] RVM + Nginx + Passenger in Chef

查看:82
本文介绍了RVM + Nginx +厨师长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用用于Nginx的社区食谱和用于RVM的fnichol's在Chef中的RVM上与乘客"一起设置Nginx. ubuntu上的所有内容.

I'm trying to setup Nginx with Passenger on RVM in Chef using community cookbook for nginx and fnichol's for RVM. Everything on ubuntu.

现在,我的问题是,如果我使用EC2刀引导机器并尝试一次性安装所有组件,它将失败.

Now, my problem is that if I bootstrap the machine using knife ec2 and try to install everything in one go, it fails.

在大多数情况下,它运行良好,可以很好地拾取RVM和Passenger,直到意识到未编译Passenger之前,尝试使用默认ruby 1.9.1中的rake进行操作,然后失败.

For the most part it works well, picking up RVM and Passenger nicely, until the point when it realizes Passenger is not compiled, tries to do it using rake from default ruby 1.9.1 and fails.

如果我随后连接到计算机并运行sudo chef-client,则所有操作均完成得很漂亮,并且我已正确配置了计算机.为什么在第一次运行时不起作用? 第一次运行时我缺少什么设置/路径元素/环境变量?

If I then connect to the machine and run sudo chef-client, everything finishes beautifully and I have correctly configured machine. Why doesn't it work on the first run? What setting/path element/environment variable am I missing during the first run?

我的食谱很简单:

include_recipe "chef_gem"
include_recipe "rvm::system"
include_recipe "rvm::gem_package"

group "rvm" do
  action :modify
  members "ubuntu"
  append true
end

include_recipe "nginx::source"

我的属性减少了一些,

# rvm                                                                                                                                                                                                                                                                         
normal['rvm']['rubies'] = ['2.1.0']
normal['rvm']['default_ruby'] = node['rvm']['rubies'].first
normal['rvm']['user_default_ruby'] = node['rvm']['rubies'].first
normal['rvm']['gems'][node['rvm']['default_ruby']] = [{name: "bundler"}, {name: "rake"}]

# nginx                                                                                                                                                                                                                                                                       
normal['nginx']['version'] = '1.4.5'
normal['nginx']['dir'] = '/etc/nginx'
normal['nginx']['log_dir'] = '/var/log/nginx'
normal['nginx']['binary'] = "/opt/nginx-#{node['nginx']['version']}/sbin"
normal['nginx']['source']['sbin_path'] = "#{node['nginx']['binary']}/nginx"
normal['nginx']['init_style'] = 'init'
normal['nginx']['default_site_enabled'] = false
normal['nginx']['source']['version'] = node['nginx']['version']
normal['nginx']['source']['modules'] = ["nginx::http_stub_status_module",
                                        "nginx::http_ssl_module",
                                        "nginx::http_gzip_static_module",
                                        "nginx::passenger"]
normal['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['source']['version']}"
normal['nginx']['source']['default_configure_flags'] = ["--prefix=#{node['nginx']['source']['prefix']}",
                                                        "--conf-path=#{node['nginx']['dir']}/nginx.conf",
                                                        "--sbin-path=#{node['nginx']['source']['sbin_path']}"]
normal['nginx']['source']['url'] = "http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"

# passenger                                                                                                                                                                                                                                                                   
normal['nginx']['passenger']['version'] = '4.0.37'
normal['nginx']['passenger']['ruby'] = "#{node['rvm']['root_path']}/wrappers/ruby-#{node['rvm']['default_ruby']}/ruby"
normal['nginx']['passenger']['gem_binary'] = "#{node['rvm']['root_path']}/wrappers/ruby-#{node['rvm']['default_ruby']}/gem"
normal['nginx']['passenger']['root'] = "#{node['rvm']['root_path']}/gems/ruby-#{node['rvm']['default_ruby']}/gems/passenger-#{node['nginx']['passenger']['version']}"
normal['nginx']['configure_flags'] = ["--add-module=#{node['rvm']['root_path']}/gems/ruby-#{node['rvm']['default_ruby']}/gems/passenger-#{node['nginx']['passenger']['version']}/ext/nginx"]

问题部分:

*** The Phusion Passenger support files are not yet compiled. Compiling them for you... ***
*** Running 'rake nginx CACHING=false' in /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.37/ext/nginx... ***
STDERR: /usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find rake (>= 0) amongst [] (Gem::LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
    from /opt/chef/embedded/bin/rake:22:in `<main>'
---- End output of "bash"  "/tmp/chef-script20140306-1255-1fqdatt" ----
Ran "bash"  "/tmp/chef-script20140306-1255-1fqdatt" returned 1
[2014-03-06T11:42:13+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

导致上述情况的命令是:

The command that leads to the above is:

cd nginx-1.4.5 && ./configure --prefix=/opt/nginx-1.4.5 --conf-path=/etc/nginx/nginx.conf --sbin-path=/opt/nginx-1.4.5/sbin/nginx --add-module=/usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.37/ext/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module && make && make install`

我找到了许多有关使用Passenger和RVM配置Nginx的指南,但都没有完成. 请帮助

I've found many guides to configuring Nginx with Passenger and RVM, none of them complete. Please help

推荐答案

好的,所以我要回答我自己的问题.

Ok, so I'm going to answer my own question.

在系统范围内的安装中,RVM创建一个文件/etc/profile.d/rvm.sh,该文件设置(以及其他)PATH变量.第一次运行时未加载此文件,因此我的PATH变量不包含RVM文件夹.

RVM in system-wide installation creates a file /etc/profile.d/rvm.sh that sets up (among others) PATH variable. This file is not loaded during the first run and as a result my PATH variable doesn't include RVM folders.

我在配方中添加了以下内容:

I added the following to the recipe:

ENV['PATH']="#{node['audioguide']['rvm_path']}:#{ENV['PATH']}"

和属性文件:

default['audioguide']['rvm_path'] = "#{node['rvm']['root_path']}/gems/ruby-#{node['rvm']['default_ruby']}/bin:#{node['rvm']['root_path']}/gems/ruby-#{node['rvm']['default_ruby']}@global/bin:#{node['rvm']['root_path']}/rubies/ruby-#{node['rvm']['default_ruby']}/bin"

这样,我的RVM路径可立即使用.

This way my RVM paths are available immediately for use.

顺便说一句,我将探讨在将来的部署中使用ruby-build代替rvm的可能性. RVM是一个很棒的工具,但是应该保留在开发环境中,而不是在生产服务器上.

Btw, I'm going to explore the possibility of using ruby-build in place of rvm for future deploys. RVM is a great tool but should probably be kept in development environments, not on production servers.

PATH仍然存在一些问题,因此我后来用magic_shell_environment

I still had some problems with PATH so I later replaced ENV['PATH'] with magic_shell_environment

magic_shell_environment 'PATH' do
  value "#{node[cookbook_name]['rvm_path']}:#{ENV['PATH']}"
end

整个食谱位于此处

这篇关于RVM + Nginx +厨师长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆