Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

I am using LAMP stack for development and I have a problem with making /var/www permanently writable. I use this command:

sudo chmod -R a+rwX /var/www

This works, but after putting a web app and accessing it through a browser, it show a "permission denied" error. When that happens, I have to the execute the command again.

How can I make the directory writable, permanently, without having to run the command again?


share|improve this question
create a subfolder in /var/www and change permisson for that directory. That should fix the issue – Anam Ahmed Mar 8 '13 at 6:57
Actually you should never ever make web root writable. See For security reasons why should /var/www not have chmod 777? – Goran Miskovic Mar 8 '13 at 7:09
these are some good comments above... considering the security reasons, you should keep permission for /var/www to default rwxr-xr-x and you'd probably move the required files to a sub-directory in /var/www and make changes to your *html files accordingly for the changes you've made to the document root. – precise Dec 9 '13 at 16:03

Numeric permissions can solve your problem.

sudo chmod 775 'your directory'

if you want to know why only 775 here's your answer

400 read by owner
040 read by group
004 read by anybody
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody


It will give all permission except write by anybody.

share|improve this answer

Usually the command you used should change the permissions permanently.

Try sudo chmod -R 775 /var/www/ (which basically is the same). If that doesn't work you might need to change the owner [and maybe the group] of the directory via sudo chown <user>[:<group>] /var/www/.

Also, you might consider the 'permission denied error' could be caused by insufficient access rights in your database or elsewhere.

share|improve this answer
But as @schkovich already mentioned you should not make the web root folder writeable. – David Mar 8 '13 at 7:12
NEVER EVER use "777". Not even with a test setup. I will personally visit you and clubber you with a plastic hammer if you do. "775" is more than enough. – Rinzwind Jan 10 '14 at 6:36
+Rinzwind I used 777 and am patiently waiting your visit. – Marcel Nov 30 '14 at 18:26

Your Answer


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.