PHP cannot write in docker container

拥有回忆 提交于 2019-12-06 06:49:21

Apache runs PHP with the user www-data, this user needs to have write access on your host directory ./public_html

To fix that, go to your docker-compose directory and execute the following command to change the owner of your public_htmldirectory and all files inside.

sudo chown -R www-data:www-data public_html

After that you need to allow users in the group "www-data" to edit files

# To change all the directories to 775 
# (write for user & group www-data, read for others):
find public_html -type d -exec chmod 775 {} \;

# To change all the files to 664
# (write for user & group www-data, read for others):
find public_html -type f -exec chmod 664 {} \;

In order for your current user to edit these files you need to add it to the www-data group :

sudo usermod -aG www-data $USER
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!