Deploy a Laravel project onto AWS (P1)

Tram Ho

Currently, putting a project on the server has become much easier thanks to the development of cloud technologies. One of them is Amazon Web Service (AWS). Today we will learn how to deploy a project (specifically Laravel project) to Amazon Web Service (AWS).

Set Of Essential Tools

First, in order to deploy a project to AWS, we need to prepare the basic knowledge and necessary tools.

AWS Elastic Beanstalk

As an AWS service, you can easily deploy and manage applications on AWS without paying too much attention to the server’s infrastructure. Elastic Beanstalk reduces management complexity with no choice or control restrictions. Just upload your app, and Elastic Beanstalk automatically handles details about storage size, load balancing, expansion, and fitness tracking. Besides, Elastic Beanstalk supports applications developed by Go, Java, .NET, Node.js, PHP, Python and Ruby. When you deploy your application, Elastic Beanstalk builds a selected supported platform version and provides one or more AWS resources, such as Amazon EC2 versions, to run the application. When you create 1 Elastic Beanstalk, AWS will automatically create the following services:

  • EC2 instance : configured to run web applications on the platform of your choice. Each platform runs a specific set of software, configuration files, and scripts to support a specific language version, framework, web container, or combination of languages. Most platforms use Apache or nginx as a reverse proxy in front of your web application, forward requests to it, serve static assets, and create access and error logs.
  • Instance security group : configured to allow traffic to port 80. This resource allows HTTP traffic from the load balancer to reach the version of EC2 running your web application. By default, traffic is not allowed on other ports.
  • Load balancer : configured to distribute requests to the version running your application.
  • Load balancer security group : configured to allow traffic to port 80. This resource allows HTTP traffic from the internet to reach the load balancer. By default, traffic is not allowed on other ports.
  • Auto Scaling group : configured to replace an ec2 if it is terminated or unavailable.
  • Amazon S3 bucket : The storage location for source code, logs, and other data created when you use Elastic Beanstalk.
  • Amazon CloudWatch alarms : tracks downloads on versions in your environment and is enabled if the load is too high or too low. When the alarm is triggered, your replicated Auto Scaling group will increase or decrease the response rate.
  • AWS CloudFormation stack : Elastic Beanstalk uses AWS CloudFormation to launch resources in your environment and propagate configuration changes.
  • Domain name : A domain name that routes to your web application in the form of subomain.region.elasticbeanstalk.com .

Of course when you delete Elastic Beanstalk AWS will automatically delete these services as well. To start using Elastic Beanstalk you can refer here .

AWS Elastic Beanstalk Command Line Interface (EB CLI)

To put the project on AWS Elastic Beanstalk, there are two ways: using the Elastic Beanstalk direct control panel and using the EB CLI code. The AWS Elastic Beanstalk Command Line Interface (EB CLI) is a command line that you can use to create, configure, and manage the Elastic Beanstalk environment.

To install eb cli , you need to install Pip and Python :

To verify that Python has been successfully installed:

To install Pip :

Download the pip install command from pypa.io

Run the command with Python:

Check pip has been successfully installed:

Install EB CLI :

Check EB CLI has been installed successfully:

You can find more details on how to install EB CLI here .

And of course in the end we can’t miss a Laravel ** project **

Ok so we have completed the preparation of the tools and knowledge necessary to be able to deploy a Laravel project to AWS. In the next article, I will start working with Elastic Beanstalk on the project along with you.

The article is referenced from:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-laravel-tutorial.html

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-advanced.html

Share the news now

Source : Viblo