如何使用Passenger和Apache设置RAILS_ENV?

IIl*_*Ill 5 apache ruby-on-rails passenger

我今天到处寻找正确设置RAILS_ENV for Passenger的方法.我想使用测试环境,因为该站点在我的服务器上,但我不希望它是生产,因为我有数据库问题.

我已被引导到文档的这一部分,但它对我没有任何意义.我PassengerAppEnv RAILS_ENV = 'test'在我的Apache .conf文件中找到了该网站,并且 - 如预期的那样 - 没有用.

我也已经安排RAILS_ENV = 'test'config/environment.rb我的Rails的网站,但也不能工作.

谢谢!

Jac*_*son 6

你很近,但不太正确.这是你如何设置它:

<Directory /path/to/app/public>
Allow from all
Options -Multiviews
# ^ for Apache 2.4+
Require all granted
RailsEnv development # < place desired environment here 
</Directory>
Run Code Online (Sandbox Code Playgroud)

基本上Passenger将在配置文件中看到该行,然后为您设置它.它使用更多的Apache样式语法:

 Name [space] <value>
Run Code Online (Sandbox Code Playgroud)

因此,您根本不需要所有引号或任何Ruby样式语法.