I
I
Islam Ibakaev2022-01-07 02:30:35
WordPress
Islam Ibakaev, 2022-01-07 02:30:35

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 {} \;

I thought to change it a little: specify the owner of the user, so as not to change the rights to files and folders.
# 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

What do you think about my version? Is it possible to use or is it better to use the version of the author of the post and why (if better)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question