Home » Php » php – Deploying a Laravel 4 app on AWS Elastic Beanstalk

php – Deploying a Laravel 4 app on AWS Elastic Beanstalk

Posted by: admin July 12, 2020 Leave a comment


I’ve developed an application in Laravel 4 – works perfectly on my local machine with the usual/typical laravel setup (nothing unusual going on here).

I’m now wanting to deploy the app to AWS Elastic Beanstalk (probably on a typical linux 64 bit server with php 5.4 installed)

My question is this: do I need to make any changes to files to make the application ready for deployment?

For example, are there any config files that I need to create etc? (I read about some sort of app/config/elastic file here: http:://darrennolan.com/2013/02/02/php-aws-elastic-beanstalk-rds-laravel-4-with-migrations-on-updates/ )

I’ve never deployed before so please go into as much detail as you can.

How to&Answers:

To answer your question regarding the L4 app configuration, you will surely find these posts helpful:

L4 cloud deployment problems
Laravel and Elastic Beanstalk

AWS Environment config
As per your question about the “some sort of /app/config/elsatic” thing – Laravel is able to “load” different config, based on the environment it is run in. You can set up different subfolders containing config files, for example for a testing server and production server. That way, you can safely copy files between two servers and dont have to change for example database credentails or basepath every time you sync the files. So here in the article you linked, it’s suggested to create a subfolder for the AWS environment so you can have a custom set of configs which will activate if you app is run on AWS.

how to deploy a Laravel 4 app on AWS
Here you have a short instruction . The instruction I came across (but didnt have time to test it yet) is below, but still read the above posts first. Thanks/props/kudos for the below steps go to codenamegary from the Laravel forum

Install the AWS Command Line Tool on your machine
– Requires ruby and a couple of other things

EC2 – Setup a Security Group
– Under EC2 create a new security group
– Naming conventions are whatever you want by typically I try to use something like…
– For example, for an app called “Blog” in the production environment I’d call it “blog-production-eb” meaning blog app, in production environment on elastic beanstalk
– On the group permit all HTTP / HTTPS and whatever else you might need

RDS – Setup an RDS security Group (for MySQL)
– Under RDS create a new security group
– Again, naming conventions are whatever you want but I try to follow something like…
– For example, for an app called “Blog” in the production environment I’d call it “blog-production-rds” meaning blog app, in production environment on RDS
– Permit the EC2 security group on this RDS Security Group
– You may also want to permit your own public IP on the group so you can access the DB directly from your machine
– Alternatively, setup a VPC and a gateway (whole other ball of wax) to get remote access
– Create a new RDS instance and attach it to the new RDS Security Group

EB – Create an EB App and Environment
– Under Elastic Beanstalk setup an App, Amazon 64-bit PHP nodes (or whatever)
– Setup an environment (call it whatever you like)
– Set the environment container’s document root to /public
– Set the environment container’s security group to the name of the EC2 security group you just created
– Configure your app DB connection to point at the RDS instance you created (hostname, username, password, etc)


Additionally, I would recommend checking out Chris Fidao’s TrustedProxy package, so you can get proper IP addresses when calling Request::getClientIp(): http://fideloper.com/laravel-4-trusted-proxies

(Be sure to set proxy addresses using CIDR notation.)

Another helpful source of information applicable to putting Laravel behind Amazon’s load balancers: