1

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)?

2

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 '13 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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