LoginSignup
3
2

More than 5 years have passed since last update.

ErrorException thrown with message "file_put_contents"が出た時

Last updated at Posted at 2017-11-27

Laravel で下みたいなエラーが出た時の対処法

事象

新規で環境構築した際、phpStormの自動アップロードを設定した。
その後、プログラムを編集後、ブラウザで変更を確認しようとしたときに以下のエラーが発生

ErrorException thrown with message"file_put_contents(/opt/Otsukaresama/storage/framework/sessions/E9eCntvMjVhXtg16peHQXBgGq4r80T7v7jsoZr32): failed to open stream: Permission denied" 

対処法

パーミッションがダメって言ってる。
今回はセッションに書き込めないとのこと。

1, パーミッションを確認

=>問題なし。

2, セッションの書き込みユーザーを変更してみる

apacheの設定を変更する

/etc/httpd/conf/http.conf

     59 # If you wish httpd to run as a different user or group, you must run
     60 # httpd as root initially and it will switch.
     61 #
     62 # User/Group: The name (or #number) of the user/group to run httpd as.
     63 # It is usually good practice to create a dedicated user and group for
     64 # running httpd, as with most system services.
     65 #
     66 User apache
     67 Group apache

66 User apache
67 Group apache
=>
66 User vagrant
67 Group vagrant

66行目と67行目
今はvagrantで開発しているので、User、Groupをvagrantに変更!

=> 解決!

まとめ

本来であれば、vagrantユーザーでセッションを書き込まないといけないのに、ユーザーがapacheのままだったので起こった模様。本番で動かすときは、このままじゃいけないので、Webサーバーにユーザーを追加して対処する必要がありそう( ・∇・)

参考

3
2
0

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
3
2