Skip to content

Terraform + Ansible + Docker infrastructure for hosting multiple WordPress and Laravel sites on AWS.

Notifications You must be signed in to change notification settings

raulprdev/aws-shared-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps Infrastructure

AWS infrastructure for hosting multiple WordPress and Laravel sites using Terraform, Ansible, and Docker.

Background

This project migrates several production websites from a traditional VPS to AWS. While a VPS was sufficient for running the sites, the goal was to gain hands-on experience with modern DevOps practices:

  • Infrastructure as Code with Terraform
  • Configuration Management with Ansible
  • Containerization with Docker
  • AWS Services (EC2, RDS, ALB, ECR, SSM)

Why This Approach?

There are simpler ways to host sites on AWS (Elastic Beanstalk, Lightsail) and more sophisticated ones (ECS/Fargate, Kubernetes). This architecture sits in the middle:

Approach Cost Complexity Learning Value
AWS Lightsail $ Low Limited
This Project $$ Medium High
ECS/Fargate $$$ Medium-High High
Kubernetes (EKS) $$$$ High Very High

The result is a cost-effective setup (~$70/month for 8 sites) that provides real experience with AWS, Terraform, and Ansible without the overhead of container orchestration platforms.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         Cloudflare                              │
│                       (DNS + Proxy)                             │
└────────────────────────────┬────────────────────────────────────┘
                             │
┌────────────────────────────▼────────────────────────────────────┐
│                  Application Load Balancer                      │
│               (SSL termination, routing)                        │
└────────────────────────────┬────────────────────────────────────┘
                             │
┌────────────────────────────▼────────────────────────────────────┐
│                      EC2 + Docker Compose                       │
│   ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐       │
│   │WordPress │  │WordPress │  │ Laravel  │  │ Laravel  │  ...  │
│   │ + nginx  │  │ + nginx  │  │ + nginx  │  │ + nginx  │       │
│   └──────────┘  └──────────┘  └──────────┘  └──────────┘       │
└────────────────────────────┬────────────────────────────────────┘
                             │
┌────────────────────────────▼────────────────────────────────────┐
│                        RDS MySQL                                │
│                    (shared database)                            │
└─────────────────────────────────────────────────────────────────┘

Supported Site Types

  • WordPress - PHP-FPM with WP-CLI, persistent uploads/themes/plugins
  • Laravel - PHP-FPM with queue workers and scheduler
  • Static - S3 + CloudFront distribution

Project Structure

.
├── terraform/          # AWS infrastructure (VPC, EC2, RDS, ALB)
├── ansible/            # Server configuration and deployment
└── docker/images/      # Custom Docker images for ECR

Quick Start

1. Provision Infrastructure

cd terraform/projects/shared-hosting
terraform init
terraform apply

2. Deploy Applications

cd ansible
ansible-playbook playbooks/deploy.yml

Documentation

Component Documentation
Infrastructure terraform/README.md
Deployment ansible/README.md
Docker Images docker/images/README.md

Technologies

  • Terraform - Infrastructure provisioning
  • Ansible - Configuration management via AWS SSM
  • Docker Compose - Container orchestration
  • AWS - EC2, RDS, ALB, ECR, S3, CloudFront, SSM

Cost

Current: ~$70/month for 8 production sites

Exploring optimizations like right-sizing instances based on actual usage metrics.


This infrastructure is actively maintained and serves production traffic.

About

Terraform + Ansible + Docker infrastructure for hosting multiple WordPress and Laravel sites on AWS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published