Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
What is the best way to add files to a website on a LAMP Server?

I have installed lamp on Ubuntu 12.04.

I try to access /var/www but it doesn't allow me to do anything as it says I don't have permissions.

I have tried:

gksudo nautilus - which works but its very inconvenient way of doing things.

sudo adduser ryan www-data
sudo chown -R www-data:www-data /var/www
sudo chmod g+rw /var/www

The above didn't work.

I have googled and searched this site for a solution, but all the existing possible solutions have not worked.

share|improve this question

marked as duplicate by jokerdino, Nitin Venkatesh, Thomas Ward, Ringtail, Mitch Nov 13 '12 at 11:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Hi Ryan, is this a production environment or not? – weberc2 May 14 '12 at 21:26
No just at home – RSM May 14 '12 at 21:33
up vote 3 down vote accepted

You need to use usermod.

usermod will modify your user.

You can then modify your user to be part of the www-data group.

$ sudo usermod -a -G www-data your-user

share|improve this answer
I tried that and it said: cannot lock /etc/passwd; try again later. – RSM May 15 '12 at 13:13
I had to do it on SU – RSM May 15 '12 at 15:59
I have updated it to mention sudo. – dibs May 22 '12 at 21:00

This is probably not the most secure or recommended solution, but sudo chmod 764 should give you what you need, assuming your user is an owner or group member. If not, 766 should work but that means any user on your system can write to that directory. Not secure, but if you need a quick fix it ought to work.

share|improve this answer

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