11

I need help here. I installed Laravel in my RHEL 8 Server

But I'm getting this error. I know this question already posted many times but I tried to follow the suggestion but no luck for me so far. I have no idea why.

The stream or file "/var/www/html/vpa/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

enter image description here I tried to use this command to change the permission but it didn't work .

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

sudo setenforce 0 
sudo chcon -t httpd_sys_rw_content_t storage

php artisan config:clear
php artisan config:cache
composer dump-autoload

sudo systemctl restart httpd
sudo reboot 

Nothing seems to work on my side . I don't know what else to do. Please help me

Rzj Hayabusa
  • 657
  • 2
  • 11
  • 29
  • I'm also facing this issue. I'm running my app on Nginx though. Anyway it's been some time. Have you been able to solve it on your own eventually? – Kelvin Low Dec 03 '20 at 16:10
  • 1
    I just managed to resolve my issue by running `setenforce 0`. – Kelvin Low Dec 03 '20 at 16:15
  • 2
    @KelvinLow. I found the solution in RHEL8 . You need to set chmod to 775 to folder storage and bootstrap/cache instead of 755. And yes , you need to 'setenforce 0' – Rzj Hayabusa Dec 10 '20 at 09:21
  • Good to know. Do you mind answering your own question so that other people will know that your question has been answered? – Kelvin Low Dec 10 '20 at 17:16

7 Answers7

15

on ubuntu this step solved it

php artisan config:clear

php artisan cache:clear

sudo chmod -R 775 /var/www/your_folder

sudo chown -R www-data:www-data var/www/your_folder 
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Ossim Julius
  • 151
  • 1
  • 4
2

sudo chmod +w storage/logs/laravel.log

Never use 777

Those are irresponsible permissions

Neftalí Yagua
  • 360
  • 3
  • 10
1

In my case, apart from ensuring all permissions were correct, I also had to disable SELinux.

Kelvin Low
  • 678
  • 1
  • 10
  • 23
1

I had changed my storage permission by run following command.It works for me:

step 1:

sudo chmod -R +rwX .

step 2:

sudo chown -R $(whoami) .

Najmul Hoq
  • 143
  • 1
  • 11
  • Could you please add where you are? What is the path where you're executing those commands. – Pathros Feb 07 '21 at 20:40
  • @Pathros Thank you for your query. Basically, I was working on a laravel project in visual studio code and I got that storage issue. And then I open the visual studio code *terminal and executed those commands and it worked for me. – Najmul Hoq Feb 15 '21 at 07:08
1

this work for me

sudo chown -R www-data:www-data ./storage
find ./storage -type d -exec chmod 775 {} \;
find ./storage -type f -exec chmod 664 {} \;
sudo chown www-data:www-data ./bootstrap/cache -R
find ./bootstrap/cache -type d -exec chmod 775 {} \;
sudo chown -R www-data:www-data .env
find .env -type d -exec chmod 775 {} \;
iohan sandoval
  • 179
  • 1
  • 6
0

Simply Read/Write Permission Allow run this commnad

chmod -R 755 /storage/laravel.log”
Ali Raza
  • 670
  • 5
  • 15
0

Worked for me.

sudo chown -R $USER:$USER /var/www
sudo chmod -R 755 /var/www
sudo chmod -R 755 storage/*
sudo chmod -R 755 bootstrap/*
Murat Çakmak
  • 151
  • 2
  • 7