Setting up Symfony2 application on amazon (for dummies)


I am trying to learn how to successfully deploy Symfony2 application on amazon cloud. What worked is that I started with blank Ubuntu, installed lamp-server^, svn… few other goodies and it worked perfectly.

The problem: all assets and DB were hosted on that one instance and I know it is not the right thing to do. I checked numerous sites and didn’t find any easy solution of setting real S2 application, only WordPress and alike.

My application allows users to upload images and then display them using Liip/Imagine bundle

I also checked AmazonWebServices bundle and I guess I should somehow use both of them; first one for display, second one for sending files to S3 bucket. And it also must work in my local Windows enviroment.

  1. How to solve that? Is there some really idiot-proof solution for this?
  2. RDS requires to read

    to be able to access mysql. How to do that when using parameters.yml?



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.

Leave a Reply