deploy laravel application on elastic beanstock with load balancer CloudyWP
Luke Anderson Laravel

How to Deploy Laravel on AWS EB | Step-by-Step Guide

📅 Last updated: 2 March 2026

today we are going to deploy laravel application on elastic bean stock and then connect it to rds database.

Things we need:

  1. RDS MYSQL DATABASE.

so lets have a rds database ready. i have created it and it is in public VPC. if you dont know about VPC then do not worry about it for now.

Laravel deployment process on Elastic Beanstalk

so i have following credentials set for this database. How i created this check video guide.

Hostname: in image you see “endpoint” that is our hostname.

username: admin (you can change it)

password: when we create database we can set a password.

port: 3306

in security group port 3306 should be allowed from your ip or any ip you want to connect from.

i connected using “Mysql Workbench”.

RDS database setup in AWS console

default “database” i have is called “zarx”.

EB CLI command line interface

there is nothing in it right now.

so from my local system i ran a command to add table and data into “zarx” database.

// first dump data to sql file from local database.

mysqldump -u root -p laravel > laravel.sql


// then command that pushes data to aws database table. here "database: zarx, table: users" you will have to provide password for rds.

mysql -h test-app-database.cn7unuxv9mmz.us-east-2.rds.amazonaws.com -u admin -p zarx < ./laravel.sql
Laravel deployment

my security group

Laravel deployment

from my ip at this time but you can change as you like.

Laravel side of things Now:

I have a laravel app running on my localhost docker container. when i visit localhost:8011 i get

Laravel deployment

same users right. now its time to deploy this app to beanstock. first we need to have “awscli” ready

I am using ubuntu 24.04

commands to run

// create Virtual Environment

python3 -m venv ~/.venvs/ebclisource ~/.venvs/ebcli/bin/activate

source ~/.venvs/ebcli/bin/activate

// show get something like below in command line

(ebcli) manu@DESKTOP-4JCDO3T:~/Projects/testLara$

here you can see it says “ebcli” in front.

now run these commands

pip install awsebcli

eb --version

should see something like

Laravel deployment

“testLara” is my folder were i have “www” directory with laravel code. and out side of www i have Dockerfile and docker-compose.yml. thats how it is running in local environment.

now in “www directory”. run commands

(ebcli) manu@DESKTOP-4JCDO3T:~/Projects/testLara/www$ composer install --optimize-autoloader // this command                 <---------
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.

  laravel/pail ................................................................................................................................ DONE
  laravel/sail ................................................................................................................................ DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/collision ........................................................................................................................ DONE
  nunomaduro/termwind ......................................................................................................................... DONE

79 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
(ebcli) manu@DESKTOP-4JCDO3T:~/Projects/testLara/www$ mkdir -p .ebextensions                                                <-------------
nano .ebextensions/laravel.config
(ebcli) manu@DESKTOP-4JCDO3T:~/Projects/testLara/www$ nano .ebextensions/laravel.config
(ebcli) manu@DESKTOP-4JCDO3T:~/Projects/testLara/www$ php artisan key:generate --show                                       <-------------

go outside of the “www” folder and initialize “Elastic Beanstock”.

ok follow the steps as they come according to your wish.

it might prompp you to provide credentials then please provide.

You have not yet set up your credentials or your credentials are incorrect
You must provide your credentials.
(aws-access-id):

after credentials we can proceed to create application

projec name : testLara
Instance type: t3 micro


eb create testlara-env --instance_type t3.micro
Laravel deployment
CloudyWP Team — WordPress and SEO specialists helping businesses grow online.

Frequently Asked Questions

Quick Answer

Deploying Laravel on Elastic Beanstalk involves setting up the environment, configuring RDS, and deploying your application.

How do I set up an RDS database for Laravel?

Create a new RDS instance, configure security groups to allow access from your IP, and note down the endpoint, username, password, and port.

What are the steps to deploy Laravel on Elastic Beanstalk?

Install EB CLI, create an application environment, upload your Laravel project files, and run composer install within the environment.

How do I connect my Laravel app with RDS database?

Use .env file in Laravel to store DB credentials and ensure proper configuration of security groups for network access.

What are common issues when deploying on Elastic Beanstalk?

Common issues include incorrect environment variables, missing dependencies, and network connectivity problems. Ensure all configurations match your setup.

Is it better to use RDS or EC2 for Laravel deployment?

RDS is recommended due to its managed service nature, automatic backups, and easy scalability compared to setting up a database on an EC2 instance.

Discussion

Be the first to comment

Leave a comment

Get a quote