Search

I am posting this so that anyone trying to deploy a Symphony installation on AWS will have a guide.

Elastic Beanstalk is AWS's PAAS (Platform as a Service). Essentially, it is an layer of abstraction that a PHP application like Symphony sits in. Elastic Beanstalk manages the Load Balancer and the EC2 (server) instances. It also generates a RDS (database) instance for your application to connect to.

Because EB is an application deployment service, the server can only run the application itself. Unfortunately, this makes running Symphony on AWS a little bit more difficult.

  1. User uploaded files cannot be stored on the server. When EB scales your application, it will use the original application files, which means any user uploaded files will not be on the new instance, breaking your site. Also, when you push a new version via git, it will completely wipe out the old files. Technically, AWS is not receiving just the diffs but taking a zip of the entire application and deploying that.
  2. config.php cannot be different from the local and production copy. Normally, one would change the database on the production config.php or change a symlink to another file. This cannot be done since you cannot access applications files once deployed.
  3. AWS EB does not support git submodules.

To solve #1, all uploaded media must be hosted on S3, using the s3upload_field.

To solve #2, use AWS Environment Variables. In the root of your Symphony project, create a directory .ebextensions and add a file in there .ebextensions/environment.config with the following contents: optionsettings: - optionname: APP_ENV value: local

Then open up manifest/config.php and add this to the bottom (I have also included CDI settings in case you use CDI).

###### PRODUCTION ######
if ($_SERVER['APP_ENV'] == 'production') {
    ###### DATABASE ######
    $settings['database'] = array(
        'host' => '****RDS_INSTANCE_ENDPOINT****',
        'port' => '3306',
        'user' => 'ebroot',
        'password' => '****RDS_INSTANCE_MASTER_PASSWORD****',
        'db' => 'ebdb',
        'sym_prefix' => 'sym_',
    );
    ########

    ###### CDI ######
    $settings['cdi']['mode'] = 'CdiSlave';
    $settings['cdi']['disable_blueprints'] = 'yes';
    ########
}
########

Deploy your application with git aws.push. Then open up the AWS Management Console, select Elastic Beanstalk, go to your environment, and click "Configuration". Select "Software Configuration" and change APP_ENV to "production". We are doing this because you might want to setup different environments for staging, development, etc. environment.config must be constant, so instead overwrite the variable in the AWS Console.

To solve #3, you must use Composer to install all extensions or manually put the folders in.

===============

I hope this was helpful for anyone trying to use AWS to deploy Symphony. Switching to AWS obviously has many benefits. Personally, I saw a speed improvement with Symphony's page creation from 1.5s to 0.3s (5x faster) after moving to AWS from shared hosting. Elastic Beanstalk automatically scales your application as well, so if you become really popular suddenly, you will have to do nothing manually.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details