I have spent a decent amount of time trying to install and setup Laravel/Vue.js application on AWS using Elastic Beanstalk service. I am going to wrap the process into a few articles for my ‘future me’ and hope that maybe some of you guys will also appreciate it.
In this article, we are going to create new web application using Elastic Beanstalk (EB). EB is AWS service which takes care of the application deployment based on the combination of app version and its configuration. This means that we can easily create our development, staging or production server which will be then deployed on independent machines. So, let’s start.
1. Creating EB application
First, login into your AWS and navigate to Elastic Beanstalk service dashboard clicking Services in the upper left corner. Click on the Create New Application in the right side. Fill the application name, e.g. lavue-on-aws (we will use this name through the article because it sounds nice) and click on Create. Every application in EB requires at least one environment. Without it, it’s just empty shell. So, click on the link Create one now. In the dialog, choose Web server environment, as we want to build simple web application and click on Select.
As I mentioned a little bit before, the biggest advantage of having independent environments is to have option to deploy different versions of our application to specified environments. In standard software development of medium-sized and enterprise software projects, you will definitely need at least two environments, e.g. development and production environment. For our purposes, we don’t need to create multiple environments, as our web application will be very simple one.
2. Setting up EB dev environment
Rename your Environment name to something meaningful, e.g. lavue-on-aws-dev. Have you noticed suffix dev? It is a good practice to distinguish environments by their name, so adding suffix to environment name is just one of many ways how to make it. And your guess is correct, dev means development environment. Domain name could stay same lavue-on-aws-dev, just check if the domain is available. The important step is to create proper preconfigured platform, as we don’t want to install all the software manually.
In our case, choose PHP from the Preconfigured platform dropdown selection. PHP platform means that Apache, PHP and Composer will be installed in our environment, see details here. And we are done, click on Create environment. Creating process will take a few minutes. You can check progress in the EC2 Dashboard in the Instances section. If the instance is running you should see something like at the picture below. Now, paste public DNS URL to your browser and voilà!
Note: You can imagine Elastic Beanstalk service as a parent service which is telling his children how should they behave. By children we means other AWS services, e.g. EC2 (Elastic Compute Cloud), S3 (Simple Storage), Elastic Load Balancer etc. Under the hood, EB creates EC2 instance (in other words virtual machine in the Amazon Compute Cloud) and install desired software on it, in our case it is PHP platform. Actually, we could install EC2 instance manually and configure our web application on it. But, why should we, if there is easier and more robust way using EB.
Laravel/Vue.js on AWS series:
- Creating Elastic Beanstalk web application
- Deploying app using Elastic Beanstalk CLI
- Installing Laravel
- Installing Node.js