AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)

Deploying a Symfony2 Application to Elastic Beanstalk

            Contribute to this article by editing the source directly on GitHub

This section walks you through deploying a sample application to Elastic Beanstalk using the Elastic Beanstalk Command Line Interface (EB CLI) and Git, and then updating the application to use the Symfony2 framework.

Set Up Your Symfony2 Development Environment

Set up Symfony2 and create the project structure. The following walks you through setting up Symfony2 on a Linux operating system. For more information, go to For information on running Symfony2 behind a load balancer, see How to Configure Symfony to Work behind a Load Balancer or a Reverse Proxy.

To set up your PHP development environment on your local computer

  1. Download and install composer from For more information, go to

    curl -s | php
  2. Install Symfony2 Standard Edition with Composer. Check for the latest available version. Using the following command, composer will install the vendor libraries for you.

    php composer.phar create-project symfony/framework-standard-edition symfony2_example/ <version number> cd symfony2_example


    You may need to set the date.timezone in the php.ini to successfully complete installation. Also provide parameters for Composer, as needed.

  3. Initialize the Git repository.

    git init
  4. Update the .gitignore file to ignore vendor, cache, logs, and composer.phar. These files do not need to get pushed to the remote server.

    cat > .gitignore <<EOT app/bootstrap.php.cache app/cache/* app/logs/* vendor composer.phar EOT
  5. Generate the hello bundle.

    php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml

    When prompted, accept all defaults. For more information, go to Creating Pages in Symfony2.

Next, set some configuration options. Composer dependencies require that you set the HOME or COMPOSER_HOME environment variable. Also configure Composer to self-update so that you always use the latest version.

In addition, set the root directory for your application.

To configure Composer and the root directory

  1. Create a configuration file with the extension .config (e.g., composer.config) and place it in an .ebextensions directory at the top level of your source bundle. You can have multiple configuration files in your .ebextensions directory. For information about the file format of configuration files, see Advanced Environment Customization with Configuration Files (.ebextensions).


    Configuration files should conform to YAML or JSON formatting standards. For more information, go to or, respectively.

  2. In the .config file, type the following.

    commands: 01updateComposer: command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update 1.0.0-alpha11 option_settings: - namespace: aws:elasticbeanstalk:application:environment option_name: COMPOSER_HOME value: /root - namespace: aws:elasticbeanstalk:container:php:phpini option_name: document_root value: /web

    Replace 1.0.0-alpha11 with your preferred version of composer. See for a list of available versions.

Configure Elastic Beanstalk

The following instructions use the Elastic Beanstalk command line interface (EB CLI) to configure an Elastic Beanstalk application repository in your local project directory.

To configure Elastic Beanstalk

  1. From the directory where you created your local repository, type the following command:

    eb init
  2. When you are prompted for the Elastic Beanstalk region, type the number of the region. For information about this product's regions, go to Regions and Endpoints in the Amazon Web Services General Reference. For this example, we'll use US West (Oregon).

  3. When you are prompted for the Elastic Beanstalk application to use, type the number corresponding to the option Create new Application. Elastic Beanstalk generates an application name based on the current directory name if an application name has not been previously configured. In this example, we use symfony2app.

    Enter an AWS Elastic Beanstalk application name (auto-generated value is "windows"): symfony2app


    If you have a space in your application name, make sure you do not use quotation marks.

  4. Type y if Elastic Beanstalk correctly detected the correct platform you are using. Type n if not, and then specify the correct platform.

  5. When prompted, type y if you want to set up Secure Shell (SSH) to connect to your instances. Type n if you do not want to set up SSH. In this example, we will type n.

    Do you want to set up SSH for your instances? (y/n): n
  6. Create your running environment.

    eb create
  7. When you are prompted for the Elastic Beanstalk environment name, type the name of the environment. Elastic Beanstalk automatically creates an environment name based on your application name. If you want to accept the default, press Enter.

    Enter Environment Name (default is HelloWorld-env):


    If you have a space in your application name, make sure you do not have a space in your environment name.

  8. When you are prompted to provide a CNAME prefix, type the CNAME prefix you want to use. Elastic Beanstalk automatically creates a CNAME prefix based on the environment name. If you want to accept the default, press Enter.

    Enter DNS CNAME prefix (default is HelloWorld):

After configuring Elastic Beanstalk, you are ready to deploy a sample application.

If you want to update your Elastic Beanstalk configuration, you can use the init command again. When prompted, you can update your configuration options. If you want to keep any previous settings, press the Enter key.

To deploy a sample application

  • From the directory where you created your local repository, type the following command:

    eb deploy

    This process may take several minutes to complete. Elastic Beanstalk provides status updates during the process. If at any time you want to stop polling for status updates, press Ctrl+C. Once the environment status is Green, Elastic Beanstalk outputs a URL for the application. Copy and paste the URL into your web browser to view the application.

View the Application

To view the application

  • To open your application in a browser window, type the following:

    eb open

Update the Application

After you have deployed a sample application, you can update it with your own application. In this step, we update the sample application with a simple "Hello World" Symfony2 application.

To update the sample application

  1. Add your files to your local Git repository, and then commit your change.

    git add -A && git commit -m "Initial commit"


    For information about Git commands, go to Git - Fast Version Control System.

  2. Create an application version matching your local repository and deploy to the Elastic Beanstalk environment if specified.

    eb deploy

    You can also configure Git to push from a specific branch to a specific environment. For more information, see "Using Git with EB CLI" in the topic Managing Elastic Beanstalk Environments with the EB CLI.

  3. After your environment is Green and Ready, append /web/hello/AWS to the URL of your application. The application should write out "Hello AWS!"

You can access the logs for your EC2 instances running your application. For instructions on accessing your logs, see Viewing Logs from Your Elastic Beanstalk Environment's Amazon EC2 Instances.

Clean Up

If you no longer want to run your application, you can clean up by terminating your environment and deleting your application.

Use the terminate command to terminate your environment and the delete command to delete your application.

To terminate your environment and delete the application

  • From the directory where you created your local repository, run eb terminate:

    $ eb terminate

    This process may take a few minutes. Elastic Beanstalk displays a message once the environment has been successfully terminated.