file_put_contents(…) Failed to open stream: Permission denied

Posted by

Error:

ile_put_contents(/opt/lampp/htdocs/myhospitalnow/propreshnow_nurses/admin_nurses/storage/framework/views/acc34acfcd67b56835312a7b25a00236.php): Failed to open stream: Permission denied

Solution: Fix Folder Permissions

Step 1: Set correct permissions for storage and bootstrap/cache directories

Run this from your Laravel project root:

sudo chmod -R 775 storage
sudo chmod -R 775 bootstrap/cache

This gives read/write/execute permission to the owner and group, and read/execute to others.

Step 2: Set correct ownership (especially on Linux/XAMPP)

If you’re using XAMPP on Linux, Apache usually runs as daemon or www-data, so run:

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

Or for XAMPP (may use daemon):

sudo chown -R daemon:daemon storage bootstrap/cache

Step 3: Clear compiled views and cache (optional but recommended)

php artisan view:clear
php artisan cache:clear
php artisan config:clear
php artisan route:clear

Now try:

Refresh the browser → the HTTP 500 error should be gone.

Leave a Reply

Your email address will not be published. Required fields are marked *

0
Would love your thoughts, please comment.x
()
x