I recently started using AWS, and I am trying to deploy my Symfony API to Elastic Beanstalk. I follow the steps in the tutorial but in the end I get the same result over and over:
Default route "/" returns the expected result, however all other endpoints return a 404 nginx error. I have seen similar questions been asked in other posts (see this Laravel one) but since I have never worked with nginx I do not know how to fix my issue based on those.
Any help is appreciated!
2
Answers
The production version of Symfony needs a web pack — I use Apache, see the docs
https://symfony.com/doc/current/setup/web_server_configuration.html
Basically just change the Elastic Beanstalk configuration to use Apache instead of Nginx and run this on your application code
Then commit and eb deploy and you’ll be in business.
The AWS tutorial provides a rudimentary nginx configuration file that does not provide a location definition needed by a symfony app when using api-platform. The solution is to provide your own nginx config file that provides for the proper locations
AWS elastic beanstalk provides a mechanism to update this file using the .platform folder in your develop directory.
Checkout this excellent github example by Alexander Schranz of the elastic beanstalk for a symfony app. It provides for the proper nginx configuration and also several useful deployment scripts needed by most symfony apps.