<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: João Salomão</title>
    <description>The latest articles on DEV Community by João Salomão (@joaosalomao).</description>
    <link>https://dev.to/joaosalomao</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F381095%2F1b23d99c-a57c-4d66-bcde-224f9e9fb4e7.jpeg</url>
      <title>DEV Community: João Salomão</title>
      <link>https://dev.to/joaosalomao</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joaosalomao"/>
    <language>en</language>
    <item>
      <title>Deploy Laravel application to AWS EC2 with GitHub Actions</title>
      <dc:creator>João Salomão</dc:creator>
      <pubDate>Sun, 19 Nov 2023 20:43:36 +0000</pubDate>
      <link>https://dev.to/joaosalomao/deploy-laravel-application-to-aws-ec2-with-github-actions-5gbo</link>
      <guid>https://dev.to/joaosalomao/deploy-laravel-application-to-aws-ec2-with-github-actions-5gbo</guid>
      <description>&lt;p&gt;In the past years, I deployed a couple of Laravel apps to production using AWS and Github, and from time to time I find myself looking into other projects to remember which steps I took to set up the server, GitHub, the database, etc. Well, it can be a very repetitive task so I decided to document the steps in this post and share the world.&lt;/p&gt;

&lt;p&gt;Depending on the size and requirements of the application, you have several options to deploy a Laravel application to a production environment; you may choose AWS Elastic Beanstalk (ELB), Amazon Elastic Kubernetes Service (EKS), Amazon EC2, AWS Lightsail, etc… The list of options can be very extensive. This tutorial is focused on deploying a small app to a single EC2 instance that bundles all the necessary pieces to run a Laravel application such as a web server and database which in this case will be Nginx and Postgres respectively.&lt;/p&gt;

&lt;p&gt;Even though I used AWS as a cloud provider, these steps can be easily reproduced on any other provider like DigitalOcean, GCP, Azure, or Linode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the deployment, ensure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Repository: Your Laravel application hosted on GitHub.&lt;/li&gt;
&lt;li&gt;AWS Account: Your account with permission to manage EC2.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create the EC2 Instance
&lt;/h2&gt;

&lt;p&gt;The first thing we need to do is to log in into the AWS console and navigate to the EC2 dashboard&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pF8KAVVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pcqkyugch8vh50sdn5p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pF8KAVVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pcqkyugch8vh50sdn5p.png" alt="AWS Console" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, click on the launch instance button:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eQD8QMXa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5o9jn0nr4y28e72vhp1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eQD8QMXa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j5o9jn0nr4y28e72vhp1.png" alt="Launch instance" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Define the name of your instance and choose an operational system. In this tutorial, we are going to use Ubuntu 22.04 LTS.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k_y66YTX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tytlss52epb9yk9a5x7q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k_y66YTX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tytlss52epb9yk9a5x7q.png" alt="Instance info" width="649" height="824"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a new key pair to the instance that will be used later on to connect to the instance:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--13I-Q5eR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usq23orl91915z338yef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--13I-Q5eR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usq23orl91915z338yef.png" alt="Key pair" width="800" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s very important to save this file in a secure place. If you lose it, you are not going to be able to download it again.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gZQqwjNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6c5xhwc1qdj0xiexhncu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gZQqwjNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6c5xhwc1qdj0xiexhncu.png" alt="Save key pair" width="756" height="739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s define the network settings. We are to create a new security group that will allow traffic for SSH, HTTP, and HTTPS from anywhere.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WceCeQBZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv2k90mqvlm9yebm6ib8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WceCeQBZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zv2k90mqvlm9yebm6ib8.png" alt="Network" width="800" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the launch button. You should see a success message and will be able to connect to the instance&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--njRVMINu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j518yiz2xcws8bqyu8sf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--njRVMINu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j518yiz2xcws8bqyu8sf.png" alt="Launch" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, connect to the server and update the system dependencies by running the following command:&lt;br&gt;
&lt;code&gt;bash&lt;br&gt;
sudo apt update&lt;br&gt;
sudo apt upgrade&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
