I’m new to AWS and configured a scalable WordPress website by following this guide:

https://parall.ax/blog/view/3212/how-to-run-scalable-wordpress-on-aws-amazon-web-services-tutorial

I added this script to my .ebextension folder,

packages:
  yum:
    nfs-utils: []
    jq: []
files:
  "/tmp/mount-efs.sh" :
    mode: "000755"
    content: |
      #!/usr/bin/env bash
      mkdir -p /mnt/efs
      EFS_NAME=$(/opt/elasticbeanstalk/bin/get-config environment | jq -r '.EFS_NAME')
      mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $EFS_NAME:/ /mnt/efs || true
      mkdir -p /mnt/efs/uploads
      chown webapp:webapp /mnt/efs/uploads
commands:
  01_mount:
    command: "/tmp/mount-efs.sh"
container_commands:
  01-rm-wp-content-uploads:
    command: rm -rf /var/app/ondeck/wp-content/uploads
  02-symlink-uploads:
    command: ln -snf /mnt/efs/uploads /var/app/ondeck/wp-content/uploads

Everything worked well except that every time I started a new EC2 instance, /mnt/efs/uploads would become empty. I can’t figure out what’s wrong with my configuration.

I followed this process:

  1. Used db deploy to deploy my fully configured WordPress folder onto the Elastic Beanstalk environment.

  2. Uploaded some images from the upload folder of my previous WordPress website (size: 700mb) onto /mnt/efs/uploads. (So now the new WordPress website will be the same with my previous one)

  3. Terminate this EC2 so that with auto-scaling, a new EC2 will be created. Everything in this EC2 will be the same with the terminated one, however, all the things in /mnt/efs/uploads disappeared.

Is there anything wrong with this configuration?

Thanks for helping me!

Read more here: AWS EFS becomes empty when auto scaling


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: