I'm setting up a sandbox type of server that will be used by a couple users as a development environment and knowledge base. The server will have a web frontend so I've installed Apache, MySQL and PHP.

Out of the box, everything under /var/www is owner by root:root. I haven't run a web server in a while but I'm pretty sure this isn't the best way of doing things. I vaguely remember the www-data user existing.

How can I get apache et al. to run as these users and have files in /var/www owned by that user and group (to which I can add my own user too)?

1 Answer 1


Each major OS distro supplies Apache preconfigured slightly differently. It's up to you to decide how you want your security to be configured.

If you're using a vendor supplied Apache package, try looking at the main .conf file (under Ubuntu it's called apache2.conf). Look for the User and Group directives. Either change the User and Group to the user/group that you want to own the files, or chown -R <apache user>:<apache group> /var/www.

If you're looking to allow multiple users to edit files in /var/www then you'll probably have to get creative. You could:

  • Make sure that the files in /var/www have their group set to a group that all your editing users are in.
  • Let editing users sudo to the www user to edit files.
  • Set ACLs on the files in /var/www to permit users to edit specific files.
  • Welcome to the website! And thanks for your answer, it's exactly what I was looking for. Cheers.
    – n0pe
    Jan 27, 2013 at 9:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .