为Phusion乘客应用程序设置环境变量

为Phusion乘客应用程序设置环境变量

本文介绍了为Phusion乘客应用程序设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了乘客在开发(Mac OS X),它的工作是完美的。唯一的问题是后来出现:现在我有一个自定义的 GEM_HOME 路径和ImageMagick二进制文件安装在/ usr / local 。我可以将它们放在获取源代码的shell rc文件中,并解决了从控制台产生的进程的环境变量;但乘客呢?相同的应用程序在运行时无法找到我的宝石。

解决方案

我知道两个解决方案。第一个(记录在案的)基本上与manveru的 - 直接在您的代码中设置ENV变量。



第二个是在Passenger使用的Ruby解释器周围创建一个包装,并记录了(寻找passenger_with_ruby)。要点是您创建(并将您的Apache配置中的PassengerRuby指向)/ usr / bin / ruby​​_with_env,一个可执行文件,包括:

 #/ bin / bash 
export ENV_VAR = value
/ usr / bin / ruby​​ $ *

两个工作;我想,前一种方法是一点点黑客。


I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom GEM_HOME path and ImageMagick binaries installed in "/usr/local". I can put them in one of the shell rc files that get sourced and this solves the environment variables for processes spawned from the console; but what about Passenger? The same application cannot find my gems when run this way.

解决方案

I know of two solutions. The first (documented here) is essentially the same as manveru's—set the ENV variable directly in your code.

The second is to create a wrapper around the Ruby interpreter that Passenger uses, and is documented here (look for passenger_with_ruby). The gist is that you create (and point PassengerRuby in your Apache config to) /usr/bin/ruby_with_env, an executable file consisting of:

#!/bin/bash
export ENV_VAR=value
/usr/bin/ruby $*

Both work; the former approach is a little less hackish, I think.

这篇关于为Phusion乘客应用程序设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:41