7
votes

I am getting this issue for sessions even when I have given 777 and required user and group to the folders in storage.

ErrorException in Filesystem.php line 81: file_put_contents(/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec): failed to open stream: Permission denied

How can I get rid of this issue?

at HandleExceptions->handleError('2', 'file_put_contents(/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec): failed to open stream: Permission denied', '/var/www/html/business/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', '81', array('path' => '/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec', 'contents' => 'a:5:{s:6:"_token";s:40:"Dyi8ML8zxaQJOEiVvqBpqk3noLDJTkIdqiC67qs9";s:9:"_previous";a:1:{s:3:"url";s:29:"http://XXXXX:8333";}s:22:"PHPDEBUGBAR_STACK_DATA";a:0:{}s:9:"_sf2_meta";a:3:{s:1:"u";i:1470895812;s:1:"c";i:1470895812;s:1:"l";s:1:"0";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', 'lock' => true))

3
Have you given a recursive change of permission of all the folders in storage? Could possibly work if you do chmod -R 777 storage.thefallen
All done and even issue still sameHarsimran Singh
Maybe this troubleshooting checklist will help you : stackoverflow.com/questions/36577020/…Vic Seedoubleyew

3 Answers

39
votes

I had a problem like that and doing the following solved it for me

chmod -R gu+w storage

chmod -R guo+w storage

php artisan cache:clear

Got it from the answer here

1
votes

if you try

chmod -R gu+w storage

chmod -R guo+w storage

php artisan cache:clear

and it still doesn't work.

you have two ways:

  1. Disable your SELinux (i really don't recommend this way, unless you are on training or learning)

  2. Configuring SELinux Policies for Apache Web Servers

i want to break down every steps for confirguring selinux policies assumption: you've already installed all database like mysql, postgresql, or others. you've installed web server

  1. install semanage with command "yum provides /usr/sbin/semanage"
  2. install policycoreutils-python with command "yum install -y policycoreutils-python"
  3. create policies:

a. sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/html/webapp(/.*)?"

b. sudo semanage fcontext -a -t httpd_log_t "/var/www/html/webapp/logs(/.*)?"

c. sudo semanage fcontext -a -t httpd_cache_t "/var/www/html/webapp/cache(/.*)?"

  1. Allowing ReadWrite Access:

a. sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/webapp/storage(/.*)?"

ACCESS YOUR WEBAPP

b. restorecon -Rv /var/www/html/webapp

0
votes

chmod -R gu+w storage

chmod -R guo+w storage

php artisan cache:clear

This worked for me for my laravel 8 application.