PHPStorm Editing – How to Edit /var/www Files Using PHPStorm

permissions

I want to edit the /var/www files using any editor like phpstorm or eclipse etc, without changing the default user/groups setting for /var/www.

Since phpstorm is invoke by a script, I don't know how to make the phpstorm part of www-data group so it get write permission.

What are other options otherwise?

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
    • 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.

Related Question