如何在部署后脚本中将更改目录设置为Amazon Elastick Beanstack上存在PHP应用程序的目录

时间:2014-12-03 13:15:50

标签: php deployment amazon elastic-beanstalk

我为Amazon Elastick Beanstack上现有的PHP应用程序创建了部署后脚本。该脚本在远程计算机上正确启动,但当前目录可能不是应用程序所在的目录。

如何更改路径以获取Amazon Elastick Beanstack实例上安装PHP应用程序的位置?

EBextension文件:

commands:
  create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: true
files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_change_access_rights.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      # cd $EB_CONFIG_APP_CURRENT
      chmod 777 wp-content/plugins/wp-scss/cache
      chmod 777 wp-content/themes/XXXX/css

错误记录:

2014-12-03T12:59:43.642Z] ERROR [22868] : Command execution failed: [CMD-AppDeploy/AppDeployStage1/AppDeployPostHook/99_change_access_rights.sh] command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/post/99_change_access_rights.sh
chmod: cannot access âwp-content/plugins/wp-scss/cacheâ: No such file or directory
chmod: cannot access âwp-content/themes/XXXXX/cssâ: No such file or directory (ElasticBeanstalk::ActivityFatalError)
    at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.0/lib/elasticbeanstalk/activity.rb:189:in `rescue in exec'
    ...
caused by: command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/post/99_change_access_rights.sh

1 个答案:

答案 0 :(得分:1)

您需要指定完整路径:
... chmod 777 /var/app/current/wp-content/plugins/wp-scss/cache ...