From AWS Console, go to Services and select EFS, then click Create file system.
Name the file system (e.g. ‘webserver-filesystem’) and select the TargetVPC, where the EFS will be deployed.
Click on the Create button, then click on the webserver-filesystem name of the EFS on the list, to open the details.
In the details of the webserver-filesystem file system, go to Network tab and click on the Create mount target button.
Select the Target VPC in the Virtual Private Cloud (VPC) drop down and add two mount targets.
|Availability zone||Subnet ID||Security groups|
Click Save button.
Make a note of the File system ID, you will need it later to mount the file system and to define the DNS name of the created file system. The DNS name follows format of file-system-id.efs.aws-region.amazonaws.com, so in my case it’s fs-f30ba7f6.efs.us-west-2.amazonaws.com (note that it will be different for you!).
Now, you can mount the file system temporarily into the Webserver instance to copy the source wordpress content.
SSH into your Webserver and run the following commands:
sudo apt-get update sudo apt-get install nfs-common sudo mkdir efs
Run the following command, replacing the FILE_SYSTEM_ID with File system ID of Elastic File System you have just created.
sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport FILE_SYSTEM_ID.efs.us-west-2.amazonaws.com:/ efs
Once you mounted the filesystem, copy the whole /var/www/html/wp-content folder from the web server to the mounted file system with the following command.
sudo cp -r /var/www/html/wp-content/* efs/
If you have any challenges in mounting the EFS, please check https://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-cmd-dns-name.html for more details