我如何用Passenger和Apache设置RAILS_ENV? [英] How do I set my RAILS_ENV with Passenger and Apache?
问题描述
今天我到处都在寻找为旅客正确设置RAILS_ENV的方法.现在该站点位于我的服务器上,因此我想使用测试环境,但是我不希望它成为生产环境,因为我遇到了数据库问题.
I've been everywhere today looking for the way to properly set my RAILS_ENV for Passenger. I want to use the test environment now that the site is on my server, but I don't want it to be production because I'm having database issues.
我被定向到文档的这一部分,但对我来说没有任何意义.我在该站点的Apache .conf文件中有 PassengerAppEnv RAILS_ENV ='test'
,并且-如预期的那样-无效.
I've been directed to this part of the documentation, but it didn't make any sense to me. I had PassengerAppEnv RAILS_ENV = 'test'
in my Apache .conf file for the site and -- as expected -- that didn't' work.
我还在我的Rails站点的 config/environment.rb
中设置了 RAILS_ENV ='test'
,但这也不起作用.
I've also set RAILS_ENV = 'test'
in config/environment.rb
of my Rails site, but that didn't work either.
谢谢!
推荐答案
您已经接近,但不太正确.设置方法如下:
You're close, but not quite correct. Here is how you set it:
<Directory /path/to/app/public>
Allow from all
Options -Multiviews
# ^ for Apache 2.4+
Require all granted
RailsEnv development # < place desired environment here
</Directory>
基本上,Passenger将在配置文件中看到该行,然后为您设置.它使用更多的Apache样式语法:
Basically Passenger will see the line in the configuration file and then set it for you. It uses the more Apache style syntax of:
Name [space] <value>
因此,您根本不需要所有的引号或任何Ruby样式的语法.
So you don't need all the quotes or any Ruby style syntax at all.
这篇关于我如何用Passenger和Apache设置RAILS_ENV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!