I had the same issue with my site. I didn’t want to chmod 777 the whole directory so I found the users which were making the changes in the scripts. The best way to enable this without compromising the security of your system is to add the users “colord” and “avahi” to the group which owns the folder containing your wordpress site in most cases this will probably be the “www-data” group. This solved my problems and no chmod 777. Hope this helps.