我是第一次使用 OpsWorks (Ubuntu 14.04) 部署我的应用程序,当迁移运行时我收到此错误:
无法加载数据库配置。没有这样的文件 -/srv/www/todoapp/releases/20150122121517/config/database.yml
我不明白这个错误,因为我的 Rails 应用程序中有一个/config/database.yml 并且被正确地推送到 bitbucket。
你可以在这里看到我的 .gitignore 文件:
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
最佳答案
我相信 Amazon Opsworks 会覆盖您的 database.yml
文件。您将必须添加自定义 JSON 来配置您的生产数据库。
无论如何,这就是您的 JSON 的样子。
{
"deploy": {
"app_short_name": { # this should be the short name Opsworks has given your app.
"database": {
"adapter": "postgresql", # change if you are using mysql
"encoding": "unicode",
"host": "your-host",
"port": "5432", # change if you are using mysql
"database": "your_database_name",
"pool": "10",
"username": "your_database_username",
"password": "your_database_password"
}
}
}
}
您可以在 Opsworks 堆栈设置中添加它。
- 登录您的 Opsworks
- 点击左侧边栏上的
Stack
。 - 单击
堆栈设置
按钮。 - 在底部您会看到配置管理部分。您可以在此处添加自定义 JSON 以正确配置数据库。
以上设置适用于 Postgres 数据库配置。您可能需要使用 mysql 对其进行一些更改。
我使用 Amazon RDS postgres 数据库进行了设置。 RDS还支持mysql。
希望这有助于您离部署应用更近一步。祝你好运。
关于mysql - 无法加载数据库配置。没有这样的文件 - database.yml - OpsWorks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28092004/