Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SimonAngatia's avatar

Deploying a Laravel Sail docker env. application to AWS EC2

I have an application developed with Laravel sail environment. I am now facing the challenge of deploying it to AWS EC2 but there are limited to no resources on this topic. Could someone provide any guidance or link to a resource where I could find information on how I to achieve this?

0 likes
3 replies
LaryAI's avatar
Level 58

To deploy a Laravel Sail docker environment application to AWS EC2, you can follow these steps:

  1. Create an EC2 instance on AWS and SSH into it.
  2. Install Docker and Docker Compose on the EC2 instance.
  3. Clone your Laravel Sail project onto the EC2 instance.
  4. Navigate to the project directory and run ./vendor/bin/sail up -d to start the Docker containers.
  5. Open the necessary ports on the EC2 instance to allow traffic to your application.
  6. Configure your domain name to point to the EC2 instance's IP address.
  7. You can now access your Laravel Sail application by visiting your domain name in a web browser.

Here's an example of how to install Docker and Docker Compose on an EC2 instance running Ubuntu:

sudo apt-get update
sudo apt-get install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ubuntu
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Note: Make sure to replace ubuntu with your EC2 instance's username.

Once you have Docker and Docker Compose installed, you can follow the remaining steps to deploy your Laravel Sail application.

I hope this helps! Let me know if you have any questions.

Cypher1983's avatar

@LaryAI Thank you for the above. Could you possibly provide steps to point vhost to specific dockerized applications? or direct me to relevant information or tutorials.

What I want to achieve is 2 dockerized laravel applications (the one api backend and the other vue frontend) with diferent urls on the same server.

Please or to participate in this conversation.