Strawberry_cat_guy
Strawberry_cat_guy

Reputation: 31

How do I change directory permissions for laravel logs?

I am looking for a more detailed answer from the following resolved issue "The stream or file "laravel.log" could not be opened: failed to open stream: Permission denied"

I am still new to web development and when entering the suggested command (sudo chown -R $USER:www-data storage) in the terminal I get the following error: chown: invalid group: ‘root:www-data’

I have also tried (sudo chown -R www-data:www-data /home/EXAMPLE/EXAMPLE) leading to my project folder but got the following error: chown: invalid user: ‘www-data:www-data’

I am doing this to fix a permissions issue:

The stream or file "/home/EXAMPLEURL/EXAMPLEURL/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied.

I have found the user and group is 'nobody' by using the following commands (find / -name httpd.conf | xargs grep -i "^user") and (find / -name httpd.conf | xargs grep -i "^group").

In the terminal I have tried the following command (sudo chown -R nobody:nobody /home/EXAMPLE/EXAMPLE/storage) in the storage folder, the level above it and the level above that. The terminal returns no error but the permissions error still shows on the live website

Thank you!

Upvotes: 0

Views: 1345

Answers (3)

Strawberry_cat_guy
Strawberry_cat_guy

Reputation: 31

Solution, courtesy of a kind soul named Rashedul.

The reason the above solutions didn't work was that previously the owner was nobody. Changing the owner to root allowed the change to take effect

sudo chgrp -R $USER Storage_path

Upvotes: 0

Rwd
Rwd

Reputation: 35190

Unlike Debian/Ubuntu, CentOS doesn't use www-data.

I'm pretty sure that the user and group is apache in your case. So, something like the following should do the trick:

sudo chown -R apache:apache /home/EXAMPLEURL/EXAMPLEURL/storage

Upvotes: 1

Deepak Kotian
Deepak Kotian

Reputation: 97

Run this below command in your server/terminal

chmod -R 775 storage

It changes read/write permission for the storage folder.

Upvotes: 0

Related Questions