deploy laravel application on elastic beanstock with rds
today we are going to deploy laravel application on elastic bean stock and then connect it to rds database.
Things we need:
- 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.
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”.
default “database” i have is called “zarx”.
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
my security group
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
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
“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
Be the first to comment