PhpStorm should use the same permissions as the user that runs/ launches the script (yourself). Add yourself to the www-data group, or set up a new group.
Let's say you created a new group called "www-pub" and added yourself to it as per instructions.
Remember to log out and back in to have the new group membership take effect. Test your group membership with the groups
command.
Then, change permissions of the /var/www
directory as follows:
chown -R :www-pub /var/www
- Set the group of all files in
/var/www
to "www-pub" recursively
chmod -R o+r /var/www
- Allows everyone (including apache) to read all files in
/var/www
chmod -R g+w /var/www
- Allows group members to write to all files in
/var/www
find /var/www -type d -exec chmod g+s {} \;
- sets new files to retain the group of the directory they are created in
If you need apache to also be able to write files (or read files without giving read to everyone else), add apache's user (usually "www-data") to the "www-pub" group.
Also, in PhpStorm's Deployment Options, make sure "override default permissions on (files/ directories)" are either unchecked or set to allow writing by group.
This process should also work for IntelliJ IDEA/ Webstorm.