TransWikia.com

AWS Beanstalk config file not executing at deployment

Stack Overflow Asked by jamesbcn on December 22, 2021

After multiple fails to correctly deploy my Laravel app through Beanstalk I decided to follow the basic AWS tutorial on how to create a Laravel app and deploy it to Beanstack (in order to rule it out as a cause.)

It launched and so I then added the following endpoint in routes/web.php:

Route::get('/hello', function () {
    return 'hi';
});

It failed.

I then discovered that Beanstalk switched its server from Apache to nginx just a couple of months ago! No mention of this in the Laravel tutorial despite it meaning that the two are no longer compatible in their default states.

After doing a bit of digging, I found a link to another AWS tutorial which apparently resolves the issues: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

The solution looked very simple: create a custom configuration file and store it in a .ebextensions directory called ‘.platform’ (dot platform) which would be located in the app directory.

I created a custom file called laravel.config with the inside:

location / {
    try_files $uri $uri/ /index.php?$query_string;
    gzip_static on;
}

The path to the file is:

~/my-app/.platform/nginx/conf.d/elasticbeanstalk/

I re-deployed. The api still doesn’t work…

I connected to the instance through SHH and noticed that the .platform directory isn’t there. I guess this makes sense since it’s only used at the point of deployment…

One Answer

One apparent issue is the use of wrong extensions for your nginx config files.

The file should be *.conf, not *.config as shown in the docs.

A reason why your .platform folder is ignored, could be that you maybe have it in your .gitignore or .ebignore files.

Please note that even if you fix the extension, the configuration itself may be still incorrect, which I can't verify.

Answered by Marcin on December 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP