Hi my Name is Noble Mutuwa Mulaudzi,AWS DevOps Engineer and a Linux enthusiast.
In this article i am going to show you how you can quickly deploy a php application on AWS using EB cli (without having to login to the AWS management console.
Source code: (https://github.com/Mutuwa99/Ebcli)
Introduction
Deploying a PHP application on Amazon Web Services (AWS) can be a seamless process with the help of the Elastic Beanstalk Command Line Interface (EB CLI). AWS Elastic Beanstalk provides a platform-as-a-service (PaaS) for deploying and managing applications. In this article, i will walk you through the steps to deploy your PHP application on AWS using the EB CLI, enabling you to easily scale and manage your application infrastructure.
Prerequisites:
Before we begin, make sure you have the following prerequisites in place:
An AWS account: Sign up for an AWS account if you don't have one already.
AWS CLI: Install the AWS Command Line Interface (CLI) on your local machine.
EB CLI: Install the Elastic Beanstalk Command Line Interface (EB CLI) on your local machine.
A PHP application: Have a PHP application ready for deployment.(You can download mine on my githu repo)
Step 1: Set Up AWS CLI and EB CLI:
First, you need to configure the AWS CLI with your AWS account credentials. Open your terminal and run the following command:
aws configure
Provide your AWS Access Key ID, Secret Access Key, default region, and output format when prompted.
Next, install the EB CLI by running the following command:
pip install awsebcli --upgrade --user
Step 2: Initialize the EB CLI:
In your terminal, navigate to your PHP application's directory and initialize the EB CLI by running:
eb init
Step 3: Setting up configs for our application:
When a user accesses laravel application via a web browser, the server looks directly into the "public" folder to handle the incoming request. In that case we will have to predefine the document root of our application and set it to /public
Create a folder called .ebextentions/01setup.config on your project root and paste the following:
option_settings:
- namespace: aws:elasticbeanstalk:container:php:phpini
option_name: document_root
value: /public
Follow the prompts to select your region, application name, and platform. Choose PHP as the platform for your application.
Step 4: Create an Environment:
To create an environment for your PHP application, run the following command:
eb create environment-name
Replace "environment-name" with a suitable name for your environment. This process may take a few minutes to provision the necessary AWS resources.
Step 5: Deploy Your Application:
Once the environment is created, you can deploy your PHP application by running:
eb deploy
step 6: Checking env health:
Once you have deployed your application you can check your app env health by running:
eb status
Step 7: Access Your Application:
After the deployment is complete, you can access your application using the environment URL provided by Elastic Beanstalk. Run the following command to open the application in your default browser:
eb open
yeey we have sucessfully deployed our php application on AWS through EB CLI(without logging in to the management console)
Thank you
Noble Mutuwa Mulaudzi
Top comments (0)