Answer the question
In order to leave comments, you need to log in
How do you set permissions (ownership) on woprdress files installed via docker?
Recently, for local development, I have been pulling wordpress through docker. Lifting the container, you can see that all files belong to www-data:www-data
This is not suitable for local work, you need to conjure with file permissions. There are two options that are described here :
1) add the current user (myusername) to the www-data group and change the permissions to 775 and 664 , respectively
2) change the owner to the current user ( myusername:www-data )
Which method do you prefer and why? Which one are you using?
UPDATED
I came across a post in which the author suggests executing a bash script
# try getting uid from docker, if it fails, try 33 (should work)
WWW_DATA_UID=33 # plug in your number from previous step
RESULT=$(docker-compose exec -u www-data wordpress id -u)
COMMAND_SUCCESS=$?
if [ $COMMAND_SUCCESS -eq 0 ]; then
WWW_DATA_UID=$(echo $RESULT | tr -d '\r')
fi
sudo chown -R $WWW_DATA_UID:$USER ./wp-content
sudo find ./wp-content -type d -exec chmod 775 {} \;
sudo find ./wp-content -type f -exec chmod 664 {} \;
# try getting uid from docker, if it fails, try 33 (should work)
WWW_DATA_UID=33 # plug in your number from previous step
RESULT=$(docker-compose exec -u www-data wordpress id -u)
COMMAND_SUCCESS=$?
if [ $COMMAND_SUCCESS -eq 0 ]; then
WWW_DATA_UID=$(echo $RESULT | tr -d '\r')
fi
sudo chown -R $USER:$WWW_DATA_UID./wp-content
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question