Run PHP script after deployment on AWS Elastic Beanstalk

I created a PHP script that creates a local.xml file for Magento with the necessary settings and database credentials. I need to run this after deploying the application; however, I cannot figure out how to do this. I understand that I need to create a file .configinside a directory .ebextensions. Anyone have a solution?

+2
source share
3 answers

Yup .ebextensionsis what you are looking for. To learn how to link a source, check out sample applications . There is PHP that you can also see.

For more information on .ebextensions, see this page .

Here is an example of a user command. This could be a file with a name sample.configin the directory .ebextensions:

commands:
    success_command:
        command: echo "this will be ran after launching"

Be careful if you copy and paste YAML and double-check the format. You can also use JSON, which follows a similar format.

-3
source

Technically, Josh is wrong. According to the documentation ( http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands ): command section .. "Commands are processed alphabetically by name and they start before the application and the web server and the application version file are retrieved. "

, , "container_commands", " container_ . , - , , ."

, post script ( ).

+8

Beanstalk /opt/elasticbeanstalk/hooks/appdeploy/post .

, :

commands:
  create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: true
files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/job_after_deploy.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #! / usr / bin / env bash
      / var / app / current
      ** run your PHP script here **
+6
source

All Articles