skip to Main Content

So i am running a Laravel 5.7.29 with PHP 7.2.34 on an EC2 in AWS running Amazon linux 2, i have fully set up the project and tried to run it, but whenever i connect using my EC2 Public IP and the port i get this error: Please Provide a Valid Cache path

I first check .env and ensured that CACHE_DRIVER=file, then i check config/cache.php and ensured

'default' => env('CACHE_DRIVER', 'file'), 

was there as well as


'file' => [
     'driver' => 'file',
     'path' => storage_path('framework/cache/data'),
],

Then i saw the project didn’t make "storage/framework/cache/data", so i made the folder and made sure to give both it and bootstrap/cache reading & writing permission with

sudo chmod -R 775

then to double check i used

ls -la

to check permissions and all of them were owned by root, after all of this i did

sudo php artisan cache:clear

And still got thisFailed to clear cache, what was more confusing is I used sudo and still got the error then I tried to run the server and curl the localhost and surprisingly it worked with no errors being thrown, been stuck with this issue for at least 2 days, is there any solutions to this?

Edit 1: I cloned the repo again in a different directory and tried all the other steps and still got the same error, weirdly when I did chown -R 777 bootstrap/cache storage i still got the permission error, then i revered it back to 775

2

Answers


  1. Please don’t use sudo infront of php artisan command. sudo is a program for Unix-like computer operating systems that enables users to run programs with the security privileges of another user, by default the superuser. Whereas Artisan is the command line interface included with Laravel.

    In short, simply run:

    php artisan cache:clear
    
    Login or Signup to reply.
  2. When I had issue with permission in laravel app, I ran these commands to resolve the issue. Manually creating necessary folders within storage/framework folder, then change the owner and the permission for bootstrap and storage folders

    mkdir -p storage/framework/{sessions,views,cache}
    
    sudo chown -R www-data:www-data storage
    sudo chmod -R 775 storage
    sudo chown -R www-data:www-data bootstrap/cache
    sudo chmod -R 775 bootstrap/cache
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search