The following script provides a handy way to perform a periodic backup of your databases to a S3 bucket in the form of a mysql dump encrypted in a password protected zip.


  • Install the aws cli via pip:
  • Create an s3 bucket
  • Assign a role with access to the s3 bucket to your ec2 instance


fileName="dump$(date +%y-%m-%d-%H-%M-%S)"

cd /db/bkp

mysqldump -u backup --all-databases > $fileName.sql

zip $ $fileName.sql -me9D -P <YOUR_SECRET_PASSWORD>

aws s3 cp $ s3://<YOUR_BUCKET_NAME>/$

So you’re looking to host a WordPress site in AWS using Elastic Beanstalk.

The following lines in your wp-config.php can get you going.

The line below enforces the use of a secure connection for the authentication API. It is off until you define an environment variable in your beanstalk configuration,  called FORCE_SSL_ADMIN with the value ‘true’

define('FORCE_SSL_ADMIN', getenv('FORCE_SSL_ADMIN')==='true');

If you enable secure connections on your Elastic Beanstalk load balancer and find that you keep getting redirected the line below indicates allows WP to detect that HTTPS is being used.

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)

These settings are defined as environment variables so you  don’t have to hardcode them in wp-config.php.

define('DB_NAME', getenv('RDS_DB_NAME'));
define('DB_USER', getenv('RDS_USERNAME'));
define('DB_HOST', getenv('RDS_HOST'));