117

I have my instance of the Amazon AWS running, test page is up.

I am trying to SFTP the files to the server to display my website. I have Filezilla connected to the AWS server but when I try to move the files from my local machine to the /var/www/html directory, it says permission denied.

I just figured out I CAN move the files to the /home/ec2-user directory. So my files are on the server I guess. But when I try to move them from there to the /var/www/html directory, it still won't move them, permission denied.

I've been researching this for approximately 2 hours now but I haven't been able to locate the answer to this.

Any help is greatly appreciated, i'm so close! Haha

Thanks

UPDATE

enter image description here

zburns12
  • 1,783
  • 3
  • 15
  • 16

8 Answers8

287

To allow user ec2-user (Amazon AWS) write access to the public web directory (/var/www/html),
enter this command via Putty or Terminal, as the root user sudo:

sudo chown -R ec2-user /var/www/html

Make sure permissions on that entire folder were correct:

sudo chmod -R 755 /var/www/html

Doc's:

Setting up amazon ec2-instances

Connect to Amazon EC2 file directory using Filezilla and SFTP (Video)

Understanding and Using File Permissions

Javapocalypse
  • 2,223
  • 17
  • 23
Black Sheep
  • 6,604
  • 7
  • 30
  • 51
  • 1
    Still no luck...I cd to that directory and typed that and it still says permission denied. I even tried moving it on the command line this time instead of in Filezilla – zburns12 Oct 29 '13 at 02:57
  • I just updated my original post with the result of those. It makes no sense, I can't see a reason why I shouldn't be able to just move the files over there. – zburns12 Oct 29 '13 at 03:09
  • 4
    Shoot, my fault, I forgot 'sudo' That did the trick! Thank you so very much! – zburns12 Oct 29 '13 at 03:16
  • That's precisely what I needed, @aldanux. Thank you SO MUCH. – Lino Silva May 13 '14 at 16:19
  • 1
    I have been struggling with this for a while! Thanks. – kta Jul 06 '21 at 09:36
  • Thank you! For those who did this using Bitnami (WordPress), just replace /var/www/html/ with your directory and put sudo at the beginning of each command and it should work fine! – Calum Childs Jul 15 '21 at 07:35
89

if you are using centOs then use

sudo chown -R centos:centos /var/www/html

sudo chmod -R 755 /var/www/html

For Ubuntu

sudo chown -R ubuntu:ubuntu /var/www/html

sudo chmod -R 755 /var/www/html

For Amazon ami

sudo chown -R ec2-user:ec2-user /var/www/html

sudo chmod -R 755 /var/www/html
Abhay Kochar
  • 991
  • 6
  • 3
39

In my case the /var/www/html in not a directory but a symbolic link to the /var/app/current, so you should change the real directoy ie /var/app/current:

sudo chown -R ec2-user /var/app/current
sudo chmod -R 755 /var/app/current

I hope this save some of your times :)

Oskar
  • 2,522
  • 32
  • 37
20

If you're using Ubuntu then use the following:

sudo chown -R ubuntu /var/www/html

sudo chmod -R 755 /var/www/html
Wachaga Mwaura
  • 3,310
  • 3
  • 28
  • 31
  • The first one seemed to work. Do I have to execute both? I'm using WordPress and after executing the first command a few permission's errors have come up with some plugins. – Sambuxc Apr 13 '21 at 08:11
  • @Coderhi, I'd recommend executing both since the accepted answer also follows the same pattern. Regarding your WordPress plugins. You can attempt reinstalling them afresh to the same EC2 instance. – Wachaga Mwaura Apr 15 '21 at 12:54
4

This work best everyone

chmod ugo+rwx your-folder

https://help.ubuntu.com/community/FilePermissions

Adeleye Ayodeji
  • 325
  • 3
  • 5
0

In my case, after 30 minutes changing permissions, got into account that the XLSX file I was trying to transfer was still open in Excel.

ikleiman
  • 545
  • 2
  • 6
  • 17
0

for me below worked:

chown -R ftpusername /var/app/current
Ravistm
  • 2,163
  • 25
  • 25
0

To allow user ec2-user (Amazon AWS) write access to the public web directory (/var/app/current), enter this command via Putty or Terminal, as the root user sudo:

sudo chown -R ec2-user /var/app/current

Make sure permissions on that entire folder were correct:

sudo chmod -R 755 /var/app/current
Faridul Khan
  • 1,741
  • 1
  • 16
  • 27