Bxx
Bxx

Reputation: 1625

PhpStorm - Deployment - Cannot Upload New Files

When I try to create a new file/folder in PhpStorm I get a Permission denied error. However, when I create a new file in a folder that already exists in the root directory of my server I can without any errors.

When I try to create a new file:

[2016-03-07 11:29 AM] Failed to transfer file 'C:\Users\D\PhpstormProjects\example2\test.php': could not write to "sftp://www.example.com/test.php". (Permission denied)
[2016-03-07 11:29 AM] Automatic upload completed in less than a minute: 2 items failed

When I try to create a new folder:

[2016-03-07 11:27 AM] Failed to create folder '/var/www/html/test': could not create folder "sftp://www.example.com/test". (Permission denied)
[2016-03-07 11:27 AM] Automatic upload completed in less than a minute: 1 item failed

Upvotes: 3

Views: 21884

Answers (5)

PHPirate
PHPirate

Reputation: 7572

Checklist:

  • Make sure you own the files, so if you are in the sudo group then you can do sudo chown -R myusername:sudo /var/www/html/test/. This is to make sure that it will also work for other people in the group.
  • Make sure that you have write permissions, i.e. read and write access also for the group. You can do this with sudo chmod -R 755 /var/ww/html/test/ (Unfortunately I have found that in practice you sometimes need 777 permissions, but this is not desirable.)
  • Make sure your deployment path mappings are correct, by going to Settings | Deployment | Mappings, and check that the Deployment path is indeed relative to the root path (under Connection)

Upvotes: 3

Braian Coronel
Braian Coronel

Reputation: 22867

Prior to deleting, modifying and transferring files, you need to give them the permissions to the data group for the user who will perform the operations.

$ sudo usermod -a -G www-data your_username
$ sudo chgrp -R www-data /var/www/html 
$ sudo chmod -R g+w /var/www/html

Upvotes: 4

Agafonov
Agafonov

Reputation: 1

After fixing permissions on server you need restart phpstorm. Worked for me on Ubuntu 17.10

Upvotes: -2

Bxx
Bxx

Reputation: 1625

The issue solved itself after restart.

PhpStorm support gave this answer: Please try to run File > Invalidate Caches/Restart > Invalidate and Restart.

If it still fails please send me idea.lof file as described here: https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

Upvotes: 4

miltone
miltone

Reputation: 4721

You can try this :

chmod -R 777 /var/www
chgrp www-data /var/www
chown -R www-data /var/www

useradd -G {www-data} your_username

Upvotes: 5

Related Questions