I have read that deploying an application on development environment may be one of the worst cases, but i couldn't find any real information about HOW i can change the environments of my applications and make their production databases ready?
I am using Passenger/Nginx for deployment by the way.
Edit : People you get it wrong, maybe i asked wrong, i know how to change environments by nginx, but if i change it from nginx and don't touch to my app, it crashes. There are some things i have to done to my app before i change their environment from development to production, i want info about them.
In your virtual host put following environment variable:-
<VirtualHost *:80>
DocumentRoot /var/apache2/htdocs/tutorial/Web/
ServerName dev.tutorial.local
SetEnv FLOW3_CONTEXT Production
</VirtualHost>
http://www.modrails.com/documentation/Users%20guide%20Nginx.html#RailsEnv
From the Passenger documentation, RAILS_ENV defaults to production.
If not you can specify it in the nginx configuration:
In the http configuration block.
In a server configuration block.
In a location configuration block.
In an if configuration scope.
I am not sure. but try changing environment varaible in config/environment.rb
ENV['RAILS_ENV'] ||= 'production'
Related
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.
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.
I've also set RAILS_ENV = 'test' in config/environment.rb of my Rails site, but that didn't work either.
Thanks!
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>
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>
So you don't need all the quotes or any Ruby style syntax at all.
Here is the tutorial I'm following: http://rhnh.net/2011/01/31/yaml-tutorial
I'm using the SettingsLogic gem: https://github.com/binarylogic/settingslogic
And every config file used by Settings logic works fine, but if I use the same tactics on database.yml or thinking_sphinx.yml it will not work.
My bad I didn't specified full stack info.
I'm using passenger. But I missed directive RailsEnv in apache config file.
http://www.modrails.com/documentation/Users%20guide%20Apache.html#rails_env
By default, passenger loads production environment.
Setting RailsEnv staging solved my problem. And now correct settings picked.
How i change the RAILS_ENV to staging without modify the virtual host file?
You can set it in your .htaccess file, if your host allows it:
RailsEnv staging
I am running Rails 3 and Passenger 2 and I don't know why but my page is still cached despite having this configuration (in one of my virtual hosts):
<VirtualHost *:80>
ServerName railstut.dev
ServerAlias *.railstut.dev
DocumentRoot "/home/ygamretuta/dev/railstut/public/"
RailsEnv "development"
<Directory "/home/ygamretuta/dev/railstut/">
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
I tried it in Firefox with the browser cache disabled (via web developer plugin) so I don't think there's a problem with the browser cache. I always need to restart the server to see the changes made (even with some minor changes like replacing a text).
What could be the problem?
EDIT
Passenger seems to be setting the environment to production despite there being a RailsEnv config option.
EDIT
Passenger runs on production environment as seen on some of my pages accessing the DB. It looks for the database name configured in the production section in the database.yml file.
http://groups.google.com/group/phusion-passenger/browse_thread/thread/ddb9dbbad0bfe679
If you have existing file cache page cache entries, they will supercede the dynamic request even after restarting. You should clear your tmp or cache directories if you have ever used the file store for caching.
I have a rails 3 app (which I upgraded). It runs on passenger and nginx but on my production server it also starts with the environment set to 'production'. I know I am missing something really basic, but I just can't figure out where to set the environment instead of in environment.rb.
Thanks for helping!
UPDATE: ok, I learned I can still do that with Rails.env = 'production'.
That seems kind of old school to me. Do you know an elegant way to configure this maybe in the Capfile or sth like that?
Rails 3 is a little bit different than Rails 2.x in that it has a config.ru file, like other Rack applications.
Passenger detects rails as a Rack app, so you'll have to use RackEnv instead of RailsEnv in the vhost. You can set the environment using RackEnv as per the documentation for Passenger/Nginx.
You can configure a different RAILS_ENV for each app in your vhost for nginx with passenger. I've never used nginx but in apache it's just a RailsEnv=development directive. That way each site just has it set, no worries with configuring a cap task or variable or anything. See the docs. Note that the default is production so this should already be set for you.