dimanche 21 avril 2019

Laravel - AWS Beanstalk - Storage symlink not working (403 error)

I am using elastic beanstalk to deploy my laravel application. Everything is working fine except for my images as I need to create a symbolic link with storage to access it publically.

P.S. Works fine on my local

My .ebextensions file is as follows -

commands:
  composer_update:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root

container_commands:
  01-install_dependencies:
    command: "php /usr/bin/composer.phar install"
    cwd: "/var/app/ondeck"
  02_storage_sym_link:
    command: "php artisan storage:link"
    cwd: "/var/app/ondeck"
    leader_only: true

Below is the log from my ec2 instance to confirm that the command worked just fine and the link was created successfully.

[2019-04-21T15:47:16.899Z] INFO  [21538] - [Application update symlink alt2@208/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Synchro/Test for Command 02_storage_sym_link] : Starting activity...
[2019-04-21T15:47:16.903Z] INFO  [21538] - [Application update symlink alt2@208/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Synchro/Test for Command 02_storage_sym_link] : Completed activity. Result:

  Completed successfully.
[2019-04-21T15:47:16.903Z] INFO  [21538] - [Application update symlink alt2@208/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Synchro/Command 02_storage_sym_link] : Starting activity...
[2019-04-21T15:47:17.014Z] INFO  [21538] - [Application update symlink alt2@208/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_Synchro/Command 02_storage_sym_link] : Completed activity. Result:
  The [public/storage] directory has been linked.

The error I am getting is as follows which makes the images unavailable for public access.

Forbidden
You don't have permission to access /storage/blog/images/8Yhb4OZJQIKwlMGaGE803niTxyjfzNSVTj2BiPaP.gif on this server.

Any help guiding me to the right path is appreciated. Cheers!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire