AWS Elastic Beanstalk Drupal 8 安装错误:未能创建符号链接“站点/默认/文件”:

Posted

技术标签:

【中文标题】AWS Elastic Beanstalk Drupal 8 安装错误:未能创建符号链接“站点/默认/文件”:【英文标题】:AWS Elastic Beanstalk Drupal 8 Install Error: failed to create symbolic link 'sites/default/files': 【发布时间】:2018-07-23 05:12:21 【问题描述】:

解决方案更新: 我没有压缩目录,而是选择了目录中的所有文件和文件夹并压缩了它们。然后我将压缩文件夹的权限更改为 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:未能创建符号链接 'sites/default/files':没有这样的文件或目录。 elastic-beanstalk/.ebextensions/efs-mount.config 中的 container_command 2link 失败。有关更多详细信息,请使用控制台或 EB CLI 检查 /var/log/eb-activity.log。

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

环境仪表板:

活动日志:

[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.'

【问题讨论】:

单实例还是负载均衡?另外,eb 活动日志是什么样的? 您是否已经设置了 RDS 实例? 单实例。是的,RDS 已设置完毕。 您可以分享您的efs-mount.config 文件的内容吗? 您能否在config 文件中添加一个额外的步骤,例如:container_commands: 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" 【参考方案1】:

使用解决方案更新: 在 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 安装页面。

【讨论】:

以上是关于AWS Elastic Beanstalk Drupal 8 安装错误:未能创建符号链接“站点/默认/文件”:的主要内容,如果未能解决你的问题,请参考以下文章

AWS Elastic Beanstalk CLI 安装错误

text AWS Elastic Beanstalk

HTTPS Elastic Beanstalk (AWS) 到 Android

AWS Elastic Beanstalk 无法担任角色

AWS Elastic Beanstalk

AWS Elastic Beanstalk chown PythonPath 错误