When I try to place my web files into /var/www in apache on my ec2 Ubuntu instance it is giving me an error stating that I don't have permission.

Permission denied.
Error code: 3
Error message from server: Permission denied
Request code: 3

How do I give myself permission to do this or what is the best way to copy files to /var/www with WinSCP?

link|improve this question
feedback

2 Answers

Enable write permissions for the user logging in thru WinSCP. There are two ways to do this.

The first way is to change the permissions on the folder to allow anyone to write to it. This isn't the best security.

chmod 777 /var/www


The second way is to add your user to the group owning the directory, and then setting permissions for the group to write to the directory.

Find out who owns the directory:

ls -l /var | grep www

You'll see something like: drwxr-x--- 9 www-data www-data 4096 Jul 14 2009 www The important thing to note are the two names root and root. In this case, the owner of the directory is www-data, and the group of the directory is www-data. So now you'll add your user to group www-data.

usermod -G www-data user

Now just add the write permission to the group.

chmod 770 /var/www

Now
ls -l /var | grep www
should return: drwxrwx--- 9 www-data www-data 4096 Jul 14 2009 www

With this you'll be able to write to the directory, while not opening up write privileges to everyone.

link|improve this answer
feedback

You need to give the user write permissions, remember the previous permissions using stat /var/www.

Then you can change them withsudo chmod 666 /var/www and change them back later when needed.

Consult man chmod and man sudo alongside other file permission manuals on the internet for more info...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.