Two options (both carried out as root
):
First
If you're happy to have me
be a member of the www-data
group:
Add the user me
to the www-data
group:
# usermod -a -G www-data me
Set the SetGID flag on the invoices
directory:
# chmod g+s /<path>/<to>/invoices
Now, any files created in the invoices
directory will have their group set to www-data
(the group of the directory) due to the SetGID bit being set. As the user me
is in this group, then the user will have permission to write to that file.
Second
If you don't want the user me
to be a member of the www-data
group, then...
Create a new group - invoices
.
# groupadd invoices
Add the users me
and www-data
to this group.
# usermod -a -G invoices me
# usermod -a -G invoices www-data
Change the group of the invoices
directory to this new group (invoices
).
# chown .invoices /<path>/<to>/invoices
Make sure that the group invoices
has write permission on the directory:
# chmod g+w /<path>/<to>/invoices
Set the SetGID flag on the invoices
directory:
# chmod g+s /<path>/<to>/invoices
Now, the invoices
directory will be owned by the invoice
group and any files created within it will have their group set to invoices
due to the SetGID bit being set on the directory. Both me
and www-data
have write permission as they are members of the invoices
group which has this write permission.
Best Answer
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
/var/www
to "www-pub" recursivelychmod -R o+r /var/www
/var/www
chmod -R g+w /var/www
/var/www
find /var/www -type d -exec chmod g+s {} \;
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.