Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dohisev's avatar

laravel.log could not be opened: failed to open stream: Permission denied

I just installed Laravel on a centos server and it doesn't work due the permissions. I was wondering how to solve this?

0 likes
15 replies
dohisev's avatar

I was reading that 777 isn't safe so that is why I came here to ask you guys about that... and also reading the docs it says that I need permision on storage folder and bootstrap or something like that.

dohisev's avatar

I saw that thread and tried to run the commands but most of them the server says invalid user for chown and invalid group for chgrp.

Talinon's avatar

I think CentOS uses 'apache' for group ownership, not 'www-data'

Snapey's avatar

you should not need to change ownership of anything, just concentrate on permissions.

Delete any Log file that already exists in case it is not owned by the webserver

1 like
dohisev's avatar

The only permission that works is setting 0777 to storage, other than that doesn't work.

1 like
sanjayacloud's avatar

Try this inside your project folder

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

HamidNE's avatar

Fixed my problem with this command in centos 7.6 Server

chcon -R -t httpd_sys_content_t $SITE_PATH
 
chcon -R -t httpd_sys_rw_content_t $SITE_PATH
4 likes
devnote's avatar

These commands were helpful:

sudo chgrp -R www-data storage bootstrap/cache

sudo chmod -R ug+rwx storage bootstrap/cache

2 likes
devnote's avatar

Mostly in ubuntu changing ownership to www-data and 775 permission solve this problem. But in centos this seems not enough. So you can run below command your projects root directory:

sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/
sudo chmod -R gu+w bootstrap/cache/
sudo chmod -R guo+w bootstrap/cache/
1 like
AMubarak's avatar

@HamidNE Such a post it's too old but you helped me a lot thank you so much. For RHEL distros, I have been using Ubuntu for quite a while. When I switched to Fedora, I was unaware that SELinux was enabled by default, which has restrictive policies unlike Ubuntu, so such commands were mentioned about adjusting SELinux to allow Apache to read and write to specific locations.

Please or to participate in this conversation.