elastic_beanstalk_restart_app_servers

Install WP CLI in Elastic Beanstalk

While working with WordPress deployments on the AWS Elastic Beanstalk platform, it can be useful to install the WP CLI tool to facilitate the creation of duplicate environments (changing the site URL, for example).

Rather than create a new AMI, I create the file .ebextensions/30_wpcli.config in the codebase with the following content:

commands:
  "01":
    command: curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp
  "02":
    command: chmod +x /usr/local/bin/wp

Deploying this change to your application will result in WP CLI being installed every time a new instance is brought online. You can apply this to existing servers using the “Restart App Server(s)” action in the Elastic Beanstalk console, but this will likely interrupt service to your application.

elastic_beanstalk_restart_app_servers