amazon-web-services - AWS Elastic Beanstalk Drupal 8 安装错误 : failed to create symbolic link 'sites/default/files' :

标签 amazon-web-services amazon-elastic-beanstalk drupal-8

解决方案更新:
我没有压缩目录,而是选择了目录中的所有文件和文件夹并压缩了它们。然后我将压缩文件夹的权限更改为 777。
此外,在 efs-mount.config 文件中,我将命令更改为:

1chown:
    command: "chown webapp:webapp /drupalfiles"
  2create: 
    command: "sudo -u webapp mkdir -p sites/default/files" 
  3link: 
    command: "sudo -u webapp ln -s /drupalfiles sites/default/files"

原始问题:我对 AWS 和 Drupal 都很陌生。

我正在尝试按照本文档在 AWS Elastic Beanstalk 上安装 Drupal 8:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-hadrupal-tutorial.html#php-hadrupal-tutorial-launch

当我进入“启动 Elastic Beanstalk 环境”时,我不断收到此错误,并且我永远无法进入 Drupal 8 安装屏幕。

命令在实例上失败。返回码:1 输出:ln:未能创建符号链接(symbolic link) 'sites/default/files':没有这样的文件或目录。 elastic-beanstalk/.ebextensions/efs-mount.config 中的 container_command 2link 失败。有关更多详细信息,请使用控制台或 EB CLI 检查/var/log/eb-activity.log。

我已确保将此文件夹和所有递归文件夹权限设置为读写。

环境仪表板:
enter image description here

事件记录:
[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore] : Starting activity...
[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent] : Starting activity...
[2018-02-19T19:15:07.237Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent/10-config.sh] : Starting activity...
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent/10-config.sh] : Completed activity. Result:
Log streaming option setting is not specified, ignore cloudwatch logs setup.

Disabled log streaming.
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore/ConfigCWLAgent] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logstreaming/hooks/config.
[2018-02-19T19:15:07.495Z] INFO  [31021] - [Application restart/AddonsBefore] : Completed activity.
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0] : Starting activity...
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook] : Starting activity...
[2018-02-19T19:15:07.496Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook/10_configure_php.sh] :     Starting activity...
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook/10_configure_php.sh] : Completed activity. Result:
 Using configuration value for DocumentRoot: 
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0/RestartAppServerPreHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/pre.
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage0] : Completed activity. Result:
Application restart - Command CMD-RestartAppServer stage 0 completed
[2018-02-19T19:15:08.567Z] INFO  [31021] - [Application restart/RestartAppServerStage1] : Starting activity...
[2018-02-19T19:15:08.568Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook] : Starting activity...
[2018-02-19T19:15:08.568Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook/01_restart.sh] :     Starting activity...
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook/01_restart.sh] : Completed activity. Result:
  Equivalent Upstart operations: start httpd, stop httpd, restart httpd, status httpd
  Stopping httpd
  httpd stop/waiting
  Starting httpd
  httpd start/running, process 31087
  [OK]
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerEnactHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/enact.
[2018-02-19T19:15:08.680Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerPostHook] : Starting activity...
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/RestartAppServerStage1/RestartAppServerPostHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/restartappserver/post.
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/RestartAppServerStage1] : Completed activity. Result:
 Application restart - Command CMD-RestartAppServer stage 1 completed
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/AddonsAfter] : Starting activity...
[2018-02-19T19:15:08.681Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation] : Starting activity...
[2018-02-19T19:15:08.682Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
 Disabled forced hourly log rotation.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart/AddonsAfter] : Completed activity.
[2018-02-19T19:15:09.048Z] INFO  [31021] - [Application restart] : Completed activity. Result:
 Application restart - Command CMD-RestartAppServer succeeded
[2018-02-19T19:34:27.980Z] INFO  [31597] - [Configuration update drupal-8.4.4@3] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent] : Starting activity...
[2018-02-19T19:34:27.981Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent/10-config.sh] : Starting activity...
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent/10-config.sh] : Completed activity. Result:
  Log streaming option setting is not specified, ignore cloudwatch logs setup.

  Disabled log streaming.
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore/ConfigCWLAgent] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logstreaming/hooks/config.
[2018-02-19T19:34:28.241Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsBefore] : Completed activity.
[2018-02-19T19:34:28.242Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0] : Starting activity...
[2018-02-19T19:34:28.242Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook] : Starting activity...
[2018-02-19T19:34:28.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/10_setup_envvars.sh] : Starting activity...
[2018-02-19T19:34:28.709Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/10_setup_envvars.sh] : Completed activity.
[2018-02-19T19:34:28.710Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/20_configure_php.sh] : Starting activity...
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook/20_configure_php.sh] : Completed activity. Result:
 Using configuration value for DocumentRoot: 
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0/ConfigDeployPreHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/pre.
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage0] : Completed activity. Result:
 Configuration update - Command CMD-ConfigDeploy stage 0 completed
[2018-02-19T19:34:29.736Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1] : Starting activity...
[2018-02-19T19:34:29.737Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook] : Starting activity...
[2018-02-19T19:34:29.738Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook/99_reload_app_server.sh] : 
 Starting activity...
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook/99_reload_app_server.sh] : Completed activity. Result:
  Equivalent Upstart operations: start httpd, stop httpd, restart httpd, status httpd
  Stopping httpd
  httpd stop/waiting
  Starting httpd
  httpd start/running, process 31677
  [OK]
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployEnactHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/enact.
[2018-02-19T19:34:29.851Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployPostHook] : Starting activity...
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1/ConfigDeployPostHook] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/configdeploy/post.
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/ConfigDeployStage1] : Completed activity. Result:
 Application restart - Command CMD-ConfigDeploy stage 1 completed
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter] : Starting activity...
[2018-02-19T19:34:29.852Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation] : Starting activity...
[2018-02-19T19:34:29.853Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation/10-config.sh] : Starting activity...
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation/10-config.sh] : Completed activity. Result:
  Disabled forced hourly log rotation.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter/ConfigLogRotation] : Completed activity. Result:
 Successfully execute hooks in directory /opt/elasticbeanstalk/addons/logpublish/hooks/config.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3/AddonsAfter] : Completed activity.
[2018-02-19T19:34:30.244Z] INFO  [31597] - [Configuration update drupal-8.4.4@3] : Completed activity. Result:
 Configuration update - Command CMD-ConfigDeploy succeeded
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs] : Starting activity...
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2018-02-19T19:44:06.592Z] INFO  [32014] - [CMD-TailLogs/TailLogs] : Starting activity...
[2018-02-19T19:44:06.593Z] INFO  [32014] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

efs-mount.config 文件:
          ##############################################
#### Do not modify values below this line ####
##############################################
container_commands:
  1chown:
command: "chown webapp:webapp /drupalfiles"
  2link:
command: "sudo -u webapp ln -s /drupalfiles sites/default/files"

option_settings:
aws:elasticbeanstalk:application:environment:
EFS_VOLUME_ID: '`{"Ref" : "FileSystem"}`'
EFS_MOUNT_DIR: '/drupalfiles'
EFS_REGION: '`{"Ref": "AWS::Region"}`'

packages:
  yum:
nfs-utils: []
jq: []

commands:
  01_mount:
 command: "/tmp/mount-efs.sh"

files:
 "/tmp/mount-efs.sh":
  mode: "000755"
  content : |
    #!/bin/bash

    EFS_REGION=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_REGION')
    EFS_MOUNT_DIR=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_MOUNT_DIR')
    EFS_VOLUME_ID=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_VOLUME_ID')

    echo "Mounting EFS filesystem ${EFS_DNS_NAME} to directory ${EFS_MOUNT_DIR} ..."

    echo 'Stopping NFS ID Mapper...'
    service rpcidmapd status &> /dev/null
    if [ $? -ne 0 ] ; then
        echo 'rpc.idmapd is already stopped!'
    else
        service rpcidmapd stop
        if [ $? -ne 0 ] ; then
            echo 'ERROR: Failed to stop NFS ID Mapper!'
            exit 1
        fi
    fi

    echo 'Checking if EFS mount directory exists...'
    if [ ! -d ${EFS_MOUNT_DIR} ]; then
        echo "Creating directory ${EFS_MOUNT_DIR} ..."
        mkdir -p ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ]; then
            echo 'ERROR: Directory creation failed!'
            exit 1
        fi
        chmod 777 ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ]; then
            echo 'ERROR: Permission update failed!'
            exit 1
        fi
    else
        echo "Directory ${EFS_MOUNT_DIR} already exists!"
    fi

    mountpoint -q ${EFS_MOUNT_DIR}
    if [ $? -ne 0 ]; then
        AZ=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
        echo "mount -t nfs4 -o nfsvers=4.1 ${AZ}.${EFS_VOLUME_ID}.efs.${EFS_REGION}.amazonaws.com:/ ${EFS_MOUNT_DIR}"
        mount -t nfs4 -o nfsvers=4.1 ${AZ}.${EFS_VOLUME_ID}.efs.${EFS_REGION}.amazonaws.com:/ ${EFS_MOUNT_DIR}
        if [ $? -ne 0 ] ; then
            echo 'ERROR: Mount command failed!'
            exit 1
        fi
    else
        echo "Directory ${EFS_MOUNT_DIR} is already a valid mountpoint!"
    fi

    echo 'EFS mount complete.'

最佳答案

解决方案更新:在 efs-mount.config 文件中,我将命令更改为:

1chown:
    command: "chown webapp:webapp /drupalfiles"
  2create: 
    command: "sudo -u webapp mkdir -p sites/default/files" 
  3link: 
    command: "sudo -u webapp ln -s /drupalfiles sites/default/files"

我使用以下命令更改了文件夹的权限:
chmod -R 777 /drupal-beanstalk
我没有压缩目录本身,而是选择了目录中的所有文件和文件夹并压缩了它们。我使用以下命令从压缩文件夹中删除了 .MACOSX:
zip -d filename.zip __MACOSX/\*

将此文件夹上传到 AWS Elastic Beanstalk 时,应用程序处于绿色健康状态,并且 URL 打开了 Drupal 安装页面。

关于amazon-web-services - AWS Elastic Beanstalk Drupal 8 安装错误 : failed to create symbolic link 'sites/default/files' :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48756536/

相关文章:

amazon-web-services - 无法修复 Amazon Athena 中的分区

amazon-web-services - AWS ECS : get public IP of the instance container when start task is called

drupal - Acquia Dev Desktop 安装后步骤出现问题

javascript - 以 drupal 形式动态生成的多个字段

amazon-web-services - 自定义 UI 的 Cognito 授权代码授予流程

spring - SimpleMessageListenerContainer Amazon SQS 轮询间隔

amazon-web-services - 在 Elastic Beanstalk 上安装 Sharp

mysql - 创建 Elastic Beanstalk 环境时,有什么方法可以在创建时在 RDS MySQL 实例中创建触发器和存储过程吗?

amazon-elastic-beanstalk - elastic beanstalk 增强健康概述 : memory is in use

html - Drupal 8.2.x 文本编辑器 stripping-removing "div classes"