skip to Main Content

I’m deploying a Laravel app on CentOS. I’ve following the following steps:

  1. Cloned my repo
  2. Installed composer
  3. Setup config

Now I’m getting the following error message when I open my website:

file_put_contents(/var/www/portal/storage/framework/sessions/IDElrNpsn0hu9hjiXAzZRUTHyzm2fqvPHSLy0ZVN): failed to open stream: Permission denied

On ubuntu I used the following command to resolve the issue:

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
chmod -R 775 storage
chmod -R 775 bootstrap/cache

Now on CentOS above 2 commands are not working and I’m getting ErrorException.
Can anyone tell me which command should I run in CentOS 7 to resolve this error?
Thanks

2

Answers


  1. Chosen as BEST ANSWER

    The issue is resolved. The solutions for centOS is to use apache instead of www-data.

    sudo chown -R $USER:apache storage
    sudo chown -R $USER:apache bootstrap/cache
    

  2. this was the only solution for me!! After 3 days and nothing to do whit permisions, chmod chown… it was the ffffff server!!

    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/bagisto/bootstrap/cache(/.)?’
    semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/bagisto/storage(/.
    )?’
    restorecon -Rv ‘/var/www/bagisto’

    see more here!
    https://laracasts.com/discuss/channels/general-discussion/file-put-contents-2

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search