我有两个(相同的)rails应用程序和nginx配置(与乘客一起使用):
> cat ./sites-available/app-production
server {
listen 80;
server_name app-development.mydomain.com;
root /path/to/my/production/app/public;
passenger_enabled on;
rails_env production;
}
> cat ./sites-available/app-development
server {
listen 80;
server_name app-development.mydomain.com;
root /path/to/my/development/app/public;
passenger_enabled on;
rails_env development;
}
两者都有./config/mongoid.yml:
development:
sessions:
default:
database: app-development
hosts:
- localhost:27017
options:
consistency: :strong
options:
production:
sessions:
default:
database: app-production
hosts:
- localhost:27017
options:
consistency: :strong
options:
但如果我同时启动它们,我会看到它们使用相同的数据库:我在development
中更改了一些数据,我也看到了production
中的更改。
如果这些配置还不够,还有哪些其他配置。或者我做错了什么?
实际上我不知道应用程序是否在不同的环境中运行。如果我停止mongodb,则两者都会呈现调试(错误)视图。看起来他们都在运行开发。如何强迫乘客运行不同的环境?我认为这项工作是通过设置rails_env
参数
所以,如果我查看mongo
:
> show dbs
app-development 0.203125GB
local (empty)
因此,未创建生产数据库。
我也执行了:
rake db:create RAILS_ENV=production
在我的生产rails应用程序中,但仍无效果。
这里提议Can't force Rails into production environment via Passenger/Nginx我删除了config.ru
,但后来我从Phusion Passenger
收到错误:
This application is a Rails 4 application, but it was wrongly detected as a Rails 1 or Rails 2 application. This is probably a bug in Phusion Passenger, so please report it.
现在(在我返回config.ru之后)它变得更糟 - 来自Phusion Passenger
的错误:
https://github.com/mongoid/mongoid.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
我做bundle install
但没有效果。
从这里is not checked out... bundle install does NOT fix help!
bundle install --deployment
现在安装所有宝石。暂时没有Phusion Passenger
错误,但我现在收到来自rails
的错误:
Permission denied - /path/to/my_rails_app/tmp/cache/assets/development/sprockets/37b5a12047376b10a57191a10d3af30a rails error
我在./tmp/
听起来像Permission denied in tmp中的类似问题。但我不知道应该申请哪个chown user:group
?我有Phusion Passenger
和nginx
。
如果我执行:
> sudo chown -R http:http ~/project/my_app/
我明白了:
chown: invalid user: `http:http'