Install Laravel on EC2 instance with Nginx server

by   AWS Laravel


Wednesday, 29 June 2016



Link to Github repo

There are pretty clear instructions on how to install Laravel with your local system on the framework's official website. But how about running it live? In this post, we'll use Amazon Web Services (AWS) to launch a single ec2 instance inside a Virtual Private Cloud (VPC) with Laravel and Nginx installed.

Context

Quick note: You'll need to have a valid AWS account to follow along. Remember, once you've registered, you'll get one year of free access to AWS resources. Click here to start.

A typical web application consists of a web server backed by a database. This will be the backbone for our architecture: an EC2 instance running inside a public subnet linked to a private MySQL database with security groups to regulate traffic between the two. This translates into a webserver being publicly accessible (we want people to be able to send requests to our webserver) and a DB instance accepting traffic from the webserver only. We'll also provide an IAM role for our EC2 instance, so that we can further attach policies to it if we need to.

architecture

Process

To see all this in action, open CloudFormation in your AWS console, click "Create New Stack" and specify the following Amazon S3 template URL:

https://s3.eu-central-1.amazonaws.com/jeanquark/aws-laravel-nginx.json

At this stage, you should already be able to have an overlook of the template. Click "Next", pick up a name for your stack and provide parameters. You can leave most options as is, but you'll need to provide a database username and password, as well the name of an existing KeyPair to enable SSH access to your instance. In case you haven't created such a KeyPair so far, visit this page. Click "Next" again, optionally specifying tags for your stack, then "Create" and wait a couple of minutes for the stack creation to complete. Finally click the link under the "Output" tab.

End Result

You are now up and running with a fresh new Laravel install on a Nginx webserver. Read this next post of mine to learn how to deploy your code from BitBucket to your newly created instance with AWS CodeDeploy.

laravel 5

Blog Search

About

Hi there! My name is Jean-Marc Kleger and I'm a web developer. Welcome to my blog where a share some tips on how to deal with a selection of challenges encountered in my day-to-day coding workflow. Most articles are related to their own Github repo so that you can quickly experiment the code. Don't hesitate also to make use of the comment section at the end of each post to share your knowledge on the topic. Enjoy the visit!