The Uploaded File Could Not Be Moved to Wp-content/uploads Efs Aws

Edifice a WordPress Site using AWS ElasticBeanstalk and EFS

Figure 1
                      
option_settings:
aws:elasticbeanstalk:awarding:environment:
FILE_SYSTEM_ID: YOUR_EFS_FILE_ID
MOUNT_DIRECTORY: '/efs'
packages:
yum:
amazon-efs-utils: []
commands:
01_mount:
command: "/tmp/mount-efs.sh"
files:
"/tmp/mount-efs.sh":
manner: "000755"
content : |
#!/bin/bash
EFS_MOUNT_DIR=$(/opt/elasticbeanstalk/bin/get-config environment -g MOUNT_DIRECTORY)
EFS_FILE_SYSTEM_ID=$(/opt/elasticbeanstalk/bin/go-config environment -chiliad FILE_SYSTEM_ID)
repeat "Mounting EFS filesystem ${EFS_FILE_SYSTEM_ID} to directory ${EFS_MOUNT_DIR} ..." echo 'Stopping NFS ID Mapper...'
service rpcidmapd status &> /dev/aught
if [ $? -ne 0 ] ; then
echo 'rpc.idmapd is already stopped!'
else
service rpcidmapd stop
if [ $? -ne 0 ] ; then
repeat 'Fault: Failed to end NFS ID Mapper!'
exit i
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
else
echo "Directory ${EFS_MOUNT_DIR} already exists!"
fi
mountpoint -q ${EFS_MOUNT_DIR}
if [ $? -ne 0 ]; then
echo "mount -t efs -o tls ${EFS_FILE_SYSTEM_ID}:/ ${EFS_MOUNT_DIR}"
mount -t efs -o tls ${EFS_FILE_SYSTEM_ID}:/ ${EFS_MOUNT_DIR}
if [ $? -ne 0 ] ; and so
echo 'ERROR: Mount command failed!'
exit 1
fi
chmod 777 ${EFS_MOUNT_DIR}
runuser -l ec2-user -c "touch ${EFS_MOUNT_DIR}/it_works"
if [[ $? -ne 0 ]]; then
echo 'ERROR: Permission Error!'
exit 1
else
runuser -l ec2-user -c "rm -f ${EFS_MOUNT_DIR}/it_works"
fi
else
repeat "Directory ${EFS_MOUNT_DIR} is already a valid mountpoint!"
fi
echo 'EFS mount complete.' repeat "creating folders (uploads)"
mkdir -p /efs/uploads
chown webapp:webapp /efs/uploads
container_commands: 01-rm-wp-content-uploads:
command: rm -rf /var/app/ondeck/wp-content/uploads
02-symlink-uploads:
command: ln -snf /efs/uploads /var/app/ondeck/wp-content/uploads

          option_settings:
aws:elasticbeanstalk:awarding:surround:
FILE_SYSTEM_ID: YOUR_EFS_FILE_ID
MOUNT_DIRECTORY: '/efs'
packages:
yum:
amazon-efs-utils: []
commands:
01_mount:
command: "/tmp/mountain-efs.sh"
files:
"/tmp/mount-efs.sh":
mode: "000755"
content : |
#!/bin/bash
EFS_MOUNT_DIR=$(/opt/elasticbeanstalk/bin/get-config environment -k MOUNT_DIRECTORY)
EFS_FILE_SYSTEM_ID=$(/opt/elasticbeanstalk/bin/get-config environment -m FILE_SYSTEM_ID)
echo "Mounting EFS filesystem ${EFS_FILE_SYSTEM_ID} to directory ${EFS_MOUNT_DIR} ..." echo 'Stopping NFS ID Mapper...'
service rpcidmapd status &> /dev/null
if [ $? -ne 0 ] ; and then
echo 'rpc.idmapd is already stopped!'
else
service rpcidmapd stop
if [ $? -ne 0 ] ; and so
repeat 'Error: Failed to finish 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
else
echo "Directory ${EFS_MOUNT_DIR} already exists!"
fi
mountpoint -q ${EFS_MOUNT_DIR}
if [ $? -ne 0 ]; and so
repeat "mount -t efs -o tls ${EFS_FILE_SYSTEM_ID}:/ ${EFS_MOUNT_DIR}"
mount -t efs -o tls ${EFS_FILE_SYSTEM_ID}:/ ${EFS_MOUNT_DIR}
if [ $? -ne 0 ] ; then
echo 'Error: Mount command failed!'
go out 1
fi
chmod 777 ${EFS_MOUNT_DIR}
runuser -l ec2-user -c "touch ${EFS_MOUNT_DIR}/it_works"
if [[ $? -ne 0 ]]; so
echo 'Mistake: Permission Error!'
exit ane
else
runuser -l ec2-user -c "rm -f ${EFS_MOUNT_DIR}/it_works"
fi
else
repeat "Directory ${EFS_MOUNT_DIR} is already a valid mountpoint!"
fi
echo 'EFS mount complete.' echo "creating folders (uploads)"
mkdir -p /efs/uploads
chown webapp:webapp /efs/uploads
container_commands:
01-cp-wp-content-uploads:
control: cp -r /var/app/ondeck/wp-content/uploads /efs/uploads
02-rm-wp-content-uploads:
control: rm -rf /var/app/ondeck/wp-content/uploads
03-symlink-uploads:
command: ln -snf /efs/uploads /var/app/ondeck/wp-content/uploads

hoffmanwhatilly.blogspot.com

Source: https://hetulsheth.medium.com/building-a-wordpress-site-using-aws-elasticbeanstalk-and-efs-5ab30771731

Related Posts

0 Response to "The Uploaded File Could Not Be Moved to Wp-content/uploads Efs Aws"

Enregistrer un commentaire

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel