【问题标题】:Rails error: unable to open database file (SQLite3::CantOpenException)Rails 错误:无法打开数据库文件 (SQLite3::CantOpenException)
【发布时间】:2013-11-10 22:57:05
【问题描述】:

我创建了一个 Rails Web 应用程序,推送到 github,然后下载到 Raspberry Pi。 运行“rake db:create RAILS_ENV=production”和 db:migrate。

当我运行 WEBrick 服务器(在生产环境中)时,它运行良好。但是当我尝试通过 Apache 运行它时,我得到了 Phusion Passenger 错误屏幕:

Web application could not be started
unable to open database file (SQLite3::CantOpenException)
 /usr/local/rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite3_adapter.rb:26:in `initialize'
/usr/local/rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite3_adapter.rb:26:in `new'
/usr/local/rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite3_adapter.rb:26:in `sqlite3_connection'

我已经将 production.sqlite3 文件的所有者和组更改为“www-data”和 chmod 666。还编辑了 database.yml 文件,使其包含数据库文件的完整路径而不是相对路径.

不知道还能尝试什么。

【问题讨论】:

  • 也许你没有迁移,所以是错误。做:rails db:迁移

标签: ruby-on-rails sqlite


【解决方案1】:

这是因为 nginx 创建了 www-data 用户,而该用户没有读取 sqlite3 文件和您的应用程序的权限...

你需要运行这个命令:

  1. sudo chown -R www-data:www-data rails_project/
  2. sudo chmod -R 777 rails_project/

【讨论】:

    猜你喜欢
    • 2011-07-24
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    • 2011-06-05
    • 1970-01-01
    相关资源
    最近更新 更多