Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

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

share|improve this answer
1  
slight correction for exactness - sudo chmod 777 /var/www - sudo usermod -G www-data (username) - sudo chmod 770 /var/www - It may work depending on who you are in your example, but 'sudo' should work no matter who you are (assuming your login is in /etc/sudoers for root/admin of course). –  bshea Sep 25 '13 at 16:32
add comment

I was getting the same error in WinSCP. One solution is to change the ownership of the '/www/' folder using chown. That way, you can make the user you log in with into the owner instead of 'root' being owner. I am using an instance of Amazon Linux rather than Ubuntu, but this command worked for me:

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

The user 'ec2-user' is the user I log in with.

Potentially Useful links

share|improve this answer
    
Your requests for help as part of an answer to someone else's question is likely to not get any responses or helpful feedback. To get that, you're probably better off asking your own question with the precise details you're needing. –  killermist Mar 28 '13 at 2:33
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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