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

Amir_P's avatar

permission denied error for laravel.log

Hi I'm trying to build a laravel project on my VPS using CentOS 7 and NGINX but I'm getting a blank screen for IP_ADDRESS and also IP_ADDRESS/index.php. This is my project structure

http://imgur.com/a/qvpvv

and the complete error is this

PHP message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/usr/share/nginx/html/laravel/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /usr/share/nginx/html/laravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107

0 likes
12 replies
Snapey's avatar

delete the log file and let nginx create a new one with the correct owner.

and FIX YOUR HOSTING you should not have /public in your URL. Set the document root so that public is /

Amir_P's avatar

I'm still getting the error. also I have change routes to print a simple word and it was working so the problem is with the view @Snapey

Amir_P's avatar

if you have time I can give you ssh access. I'm working on it for about 1 week and couldn't fix it on apache and IIS finally I switched to NGINX @Snapey

Amir_P's avatar

Ok I've fixed that and now it's the IP address of my server. but nothing changed about my problem @Snapey

ortejim's avatar

You should make sure these permissions are in place:

sudo chgrp -R www-data storage bootstrap/cache //assuming "www-data" is the user of your apache server

sudo chmod -R ug+rwx storage bootstrap/cache

Bish's avatar

Hi @amir_p

I am getting same error on CentOS - Nginx

were you able to fix it?

esorone's avatar

Are you able to run php artisan route:cache , php artisan config:cache , php artisan view:clear and php artisan cache:clear? Or do you receive an error as well? Please try them all

siangboon's avatar

the error is related to permission

failed to open stream: Permission denied in

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.

Bish's avatar

If changing permission for Storage and Bootstrap/Cache does not work for you then, it might be worth checking your SELINUX (Security Enhanced Linux) config

When I changed SELINUX mode to 'Permissive' then it worked fine.

Run command


setenforce 0

It should set the SELINUX mode to 'Permissive'.

Now try your site - hopefully it works for you too.

If you want to change SELINUX back to enforcing:

Run this command:


setenforce 1

Note: As far as I understand setting mode to permissive is not recommended - there are ways to set the SELINUX to 'enforcing' and make the Laravel Site work - which makes the site and system more secure.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security-enhanced_linux/chap-security-enhanced_linux-introduction

Please or to participate in this conversation.