how to setup symfony2 on amazon aws

Published on Author Code Father


Whilst as you can use AWS to provide standalone servers, if you wish to support multiple instances, load balancing etc, you’ll want to separate things out. At the most basic level you’ll likely want to be using:

  • S3 – persistent storage
  • RDS – MySQL database
  • EC2 – Apache / Nginx, PHP front end

You can then augment this with:

  • Cloudfront – localised delivery of your S3 content
  • Loadbalancer – ensure your EC2 instances are used optimally
  • Auto scaling – start / stop new instances
  • Route 53 – DNS
  • VPC – important as this offers security, single front ends for SSL certificates etc.

Also, rather than start from scratch you can use AMI’s from the marketplace:

Checkout the AWS getting started guide as this goes through everything in detail:

Using the above, I’d suggest moving your database to RDS and simply hosting Apache on your EC2 instances. You might even find this is cost effective too as you’ll be able to utilise small instances given the lower memory / CPU requirements.

Also, as time progresses, you can start to look at Elastic Beanstalk and Chef (maybe even vagrant for local dev boxes), Elastic Beanstalk (

So, Symfony

first up, environments

I’m assuming you’ve created production and development environments: This is important as you are able to change configuration between local and production environments.


Checkout which utilises (or the bundle:

There appears to be a good article on how to configure it here:

Using the above environments, you’d be able to configure production to read/write to s3, whereas developments write to /tmp (for example)


I’m going to make an assumption that you’re using Doctrine as your DB connection and have followed the Symfony docs on how to set up the configuration:

All you’d need to do is follow the environment logic and set the db strings production / local accordingly. This should be seamless in the background and not require manual MySQL connections.