1
votes

I am familiar with deployments using laravel apps to Aws Elastic Beanstalk, but today when trying to deploy another app (Laravel 5.7), I get this annoying exception error:

InvalidArgumentException - Please provide a valid cache path.

I have done my research, and I have tried the usual suggestions = creating folders under storage, and giving permissions, without success. Aws even tells me the following folders exist: storage/framework/[sessions, views, cache]

During deployment, everything runs perfectly, env file copied, migrations and seed is done, then deployment stops because of this error.

Here are the commands I run when deploying (ebCommands) :

commands:
    01_update_composer:
        command: export HOME=/root && export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 1.0.0-alpha11

option_settings:
    aws:elasticbeanstalk:container:php:phpini:
        document_root: /public
        memory_limit: 512M

users:
  ec2-user:
    groups:
      - webapp

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/02_configure_environment_file.sh":
      mode: "000777"
      owner: root
      group: root
      content: |
        #!/bin/bash
        if [ ! -f /var/www/html/.env ] ; then
            cp /var/www/html/.env.example /var/www/html/.env
        fi

        php  /var/www/html/artisan migrate:refresh
        php  /var/www/html/artisan db:seed
        mkdir -p /var/www/html/storage/framework/cache/data
        mkdir -p /var/www/html/storage/framework/sessions
        mkdir -p /var/www/html/storage/framework/views
        mkdir -p /var/www/html/storage/app
        mkdir -p /var/www/html/storage/logs
        mkdir -p /var/www/html/bootstrap/cache
        chmod -R 775 /var/www/html/bootstrap/cache
        chmod -R 775 /var/www/html/storage
        chmod -R 775 /var/www/html/storage/logs
        php  /var/www/html/artisan config:clear
        php  /var/www/html/artisan cache:clear
        php  /var/www/html/artisan config:cache

It should deploy and I should be able to see my website. Instead, Aws logs show : InvalidArgumentException : Please provide a valid cache path. The website shows the same error message.

I have tried various things online, but I'm stuck ! It is not the first laravel app I'm deploying. I do the deployment with CodePipeline and github automatically.

For me the issue is probably a permission issue...

Thank you !!

1

1 Answers

0
votes

The error usually occurs when the storage folders are missing from the document root. You need to ensure the following folders are present:

./storage/framework/cache ./storage/framework/sessions ./storage/framework/views