Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 just installed a LAMP server in a fresh Ubuntu system.

The main problem I have is that the webroot is at "/var/www", and my default username doesn't have access to write there. I could be sudo-ing all the time, but thats quite a pain. I've tried playing with permissions and symbolic links, but I never seem to get through the problem.

How do I setup a new developer machine so that I can quick and efficiently start developing right off the bat?

share|improve this question
Please rephrase your question. Now it sounds like you're asking for opinion and it may be put on hold. However, you can rewrite it to ask how to solve specific problem (permission issues). – gronostaj Jul 28 '13 at 12:08
@gronostaj To me it looks like that's the gist of the question, "best" is being defined clearly here, so this question is fine. – slhck Jul 28 '13 at 12:10
I've edited your question to better match what we're looking for here at Super User. Feel free to change, or even roll-back if you disagree. Ultimately I feel that this is a valid and good question (cc @slhck) – KronoS Aug 5 '13 at 14:46

Change /var/www

I would recommend you edit the /etc/apache2/sites-enabled/000-default and change the DocumentRoot and Directory to point to something along the lines of

DocumentRoot /home/USERNAME/web/


<directory /home/USERNAME/web>

instead of the ones with /var/www in them


Alternatively you can enable Userdirs, by simply

sudo mv /etc/apache2/mods-available/userdir.* /etc/apache2/mods-enabled/

Then you can access your /home/USERNAME/public_html directory from

Note: Both of these methods require you to restart apache, you can do so with

/etc/init.d/apache2 restart

I hope this helps

share|improve this answer
Good suggestions. For simplicity, the userdir module can be enabled with sudo a2enmod userdir. – slhck Jul 28 '13 at 12:27
I never even knew that existed, thanks – Marcus Hughes Jul 28 '13 at 12:29

You can create a group of users that has write permissions to the /var/www directory. For example, www-users:

sudo addgroup www-users

Then, add yourself to that group:

sudo adduser $(whoami) www-users

Finally give ownership to the group, and set group-writable permissions:

sudo chgrp www-users /var/www
sudo chmod –R 775 /var/www
sudo chmod g+s /var/www

Now, you will be able to create and modify files in /var/www as long as they also belong to your group. If you need Apache to have write access, you can adduser www-data www-users to give it write permissions as well.

share|improve this answer
Is there a way that this could be written up as a script, that runs after a fresh install of the system? Because I think that's ultimately the goal of the OP. – KronoS Aug 5 '13 at 14:44

This is a common problem, and the best solution I have found is vagrant.

Basically Vagrant is software that integrates with virtual box, and allows you to quickly spin up a VM. It is then very easy to map the /var/www directory, to the project home. Any changes made to that directory, instantly show up live on the web server.

Vagrant advantages:

  • Standardize environments for all developers though box images.
  • Automatic symbolic linking of folders
  • Quick setup/teardown
share|improve this answer

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.