DEV Community

Cover image for Deploy a PHP(Laravel) app on AWS Elastic Beanstalk via CodePipeline
Tanmay Shukla
Tanmay Shukla

Posted on • Updated on

Deploy a PHP(Laravel) app on AWS Elastic Beanstalk via CodePipeline

In this tutorial I will explain you to deploy a PHP laravel application on AWS Elastic Beanstalk service.
About : Amazon Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.
Working: You simply upload your code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, and automatic scaling to web application health monitoring, with ongoing fully managed patch and security updates.

Step-1) Create a Beanstalk Environment and APP

  • Select environment as web server environment Image1
  • Create the Application and Environment name: Image 2
  • Choose the Platform on which you want to deploy your app.Here We will choose PHP for our laravel project. Image 3
  • The next step is to upload the code(for now we will go with sample code as we will push the original code in the next version with the code pipeline.) Image 4
  • Click on create and let the enviornment get created. Image 5 Finally It will show something like this Image 6 And when you click the APP url like this http://laravelapp-env.eba-muin3rqg.us-east-2.elasticbeanstalk.com/ it will open your app with sample code. Image 7

Step-2) Create the CodePipeline

Go to searchbar, type codepipeline and click create codepipeline
Image 8

  • Now Add the source stage, connect to your version control system(like Github here) and select the repository(laraval-demo) and branch(dev) Image 9
  • Check the Start the pipeline on source code change to automatically starts your pipeline when a change occurs in the source code.
    Image 10

  • Skip the Build stage for now. Add Deployment stage (Pipelines must have at least two stages. Your second stage must be either a build or deployment stage.)
    Choose Elastic Beanstalk at the place of Deployment Provider, application name and environment name.
    Image 23
    Click Next and Review all the steps and cofiguration.
    Finally Click on Create Pipeline
    Image 23

  • After Pipeline is succesfull create and deployed it will look something like this:
    Image 24

  • Now Go to Beanstalk enviornment dashboard and open the application version you will found out that the latest version deployed is via codepipeline
    Image 26

  • See the health of our app as OK
    Image 44

  • Click on Beanstalk App URL like http://laravelapp-env.eba-muin3rqg.us-east-2.elasticbeanstalk.com/ to see our deployed laravel app.
    Image 54

Summary:

The CodePipeline will trigger whenever we will push the changes into the git. Hence it is our Continuous integration pipeline.

Top comments (1)

Collapse
 
mohamad_el_bohsaly profile image
Mohamad El Bohsaly

Why did you skip the build phase in CodePipeline?