scripts/install_dependencies 运行 作为用户 ubuntu 失败,退出代码为 1

scripts/install_dependencies run as user ubuntu failed with exit code 1

我正在尝试从 GitHub.I 部署应用程序并在 Github 中使用 appspec.yml 创建了一个存储库。 以下是我的appspec.yml:

的代码
version: 0.0
os: linux
files:
  - source: /index.html
    destination: /var/www/html/
hooks:
  BeforeInstall:
    - location: scripts/install_dependencies
      timeout: 300
      runas: ubuntu
    - location: scripts/start_server
      timeout: 300
      runas: ubuntu
  ApplicationStop:
    - location: scripts/stop_server
      timeout: 300
      runas: ubuntu

我在部署应用程序时遇到错误

Script at specified location: scripts/install_dependencies run as user ubuntu failed with exit code 1

install_dependencies 脚本以代码 1 退出,因为在安装 Apache 之前安装 Apache 需要权限。

要解决此问题,请在 install_dependencies.sh 文件

中使用带有安装命令的 -y 标志
#!/bin/bash
sudo apt-get install -y apache2