Help us understand the problem. What is going on with this article?

ErrorException thrown with message "file_put_contents"が出た時

More than 1 year has passed since last update.

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サーバーにユーザーを追加して対処する必要がありそう( ・∇・)

参考

tomoteru
加筆・修正中
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした