LoginSignup
0

More than 3 years have passed since last update.

bitnamiのRedmineでファイルアップロードするとInternal Server Errorが発生

Last updated at Posted at 2019-07-30

前提状況

AWS EC2で個別に立てていたRedmineサーバーをLightsailへ移行した。
移行した時のファイルは表示されていたが、Wikiでファイルアップロードした時にInternal Server Errorが発生。

環境情報

  • AWS LightsailのBitnami製Redmine
  • Redmine 4.0.3.stable
  • Ruby 2.5.5-p157
  • Rails 5.2.2.1

エラー関連

エラーログの場所

/home/bitnami/apps/redmine/htdocs/log/production.log

エラー内容

Saving attachment '/opt/bitnami/apps/redmine/htdocs/files/2019/07/1907300123225_dada222e5919600905458212341.pptx' (116098 bytes)
Completed 500 Internal Server Error in 11ms (ActiveRecord: 4.0ms)

Errno::EACCES (Permission denied @ rb_sysopen - /opt/bitnami/apps/redmine/htdocs/files/2019/07/1907300123225_dada222e5919600905458212341.pptx):

app/models/attachment.rb:120:in `initialize'
app/models/attachment.rb:120:in `open'
app/models/attachment.rb:120:in `files_to_final_location'
app/controllers/attachments_controller.rb:105:in `upload'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Internal Server Errorの原因は権限がないのが原因と判明。
では適切な権限とは・・・??

検証方法

確認方法としては移行したfilesディレクトリを一旦別名で退避させて、画面上でファイルをアップロードすると新規でfilesディレクトリが作成される。その時に作成されたディレクトリと同じ権限/ユーザー/グループを適切に設定してあげれば問題なし。という判断ができる。

今回の場合は権限ではなくディレクトリのユーザーとグループが違うことが原因である。

対応

Redmineのfilesを移行した時にredmineディレクトリと同様のユーザー:bitnamiグループ: bitnamiで作成されている。しかし、ファイルアップロードするユーザーorグループはdaemonであるため変更する必要がある。必要であれば775(drwxrwxr-x)権限に変更する。

sudo chown -R daemon:daemon /opt/bitnami/apps/redmine/htdocs/files
sudo chmod -R 775 /opt/bitnami/apps/redmine/htdocs/files

これでファイルアップロードができる!!!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0