Problem:

Often there is a situation that we have files created by web server with owner www-data:www-data and default access mode 0644 and we need provide access to it for some customer user. We can add our user to group www-data but anyway this user have no write permission to files created by web server. 


Solution:

1. We must add our user to group www-data

usermod -a -G www-data <user>

2. We must change umask for files created by web server to 002 instead default 022. With umask 002 web server will create new files with mode 0664 and directories with mode 0775 instead 0644 and 0755 by default. It's allow write access to this files for our user in group www-data.

2.1. for apache2 edit /etc/apache2/envvars and add umask 002 line on top of file. Or if it's already exist change 022 to 002.

2.2. for nginx + php-fpm edit /etc/init/php-fpm.conf and meke same changes as for apache2.