djangoでunable to open database file

nitrous.io でサクっと作った django のアプリ。
Raspberry Pi に無理矢理押し込んだ nginx+django マシンにデプロイしてみたらこんなエラーが出た。

unable to open database file

db.sqlite3 は www-data:www-data で 644 だから問題ないはず!


というわけでググって見つけたのはこのページ。

Django says "Unable to Open Database File" when using SQLite3」という項目にあったこれが解決策だった!

Make sure Apache can also write to the parent directory of the database. SQLite needs to be able to write to this directory. Avoid setting the permissions to 777, as it's a security risk (see ​this page for an explanation why).

あ〜、db.sqlite3 ファイルが置いてあるフォルダも Apache が読める設定でないといけないのね。(今回は nginx だけど…)


というわけで、置いてあるフォルダのユーザとグループを www-data:www-data にしてみたら、ちゃんと動作するようになりました。