'PhpStorm - unable to upload file to EC2 using SFTP

I have set up SFTP config in my PhpStorm and also added the connection via SSH.

Whenever I try to upload to the instance I get the following error in PhpStorm (example of me trying to upload index.php file):

Could not write to "sftp://........./index.php

The above is located in /var/www/html.

If I change my deployment path to /home/ec2-user and then try to upload it works without error.

Then I have tried the following but that also doesn't work:

sudo chmod 777 -R /var/www/html/
and chown

I have attached screenshot of my PhpStorm config as well. Wondering if anyone has any ideas about this.

Connection image

Deployment path image

SSH Config

Edit: Screenshot of permissions:

Inside var var

Inside www www

Example inside html Example file inside html



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source