Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
What are the best linux permissions to use for my website?

I'm searching for an easy way to organize web server directories on Linux.

Users can use FTP to upload their web pages onto the server. But if they do this, the files are owned by the user themself and the web server can't write to them.
I'm searching for a solution that

  1. allows users to upload stuff to the server
  2. allows the web server to create/delete/manipulate files
  3. allows the users to remove the web server's ability to manipulate certain files/directories for additional application security.

How would I do this?

share|improve this question

marked as duplicate by Zoredache, mdpc, Michael Hampton, Ward, Iain Dec 9 '12 at 11:58

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.

1 Answer 1

The simplest solution would be to add your web server user (www-data for example) to each user's group and set read/write permissions for the group.

Alternatively, you can use Access Control List (ACL) to set up very fine-grained permissions on files and directories, including a revoke-able (by the owner of the file) special access for your web server user. Details will depend on your distribution, consult documentation. Here's how you could do it on Ubuntu for example.

share|improve this answer
Wouldn't your first solution allow users to modify the files of another user by running scripts as the web server? Also, I'm afraid I can't use ACLs on my VPS, is there any other solution? –  OH NO WHAT IS THIS Dec 8 '12 at 1:47
> Wouldn't your first solution allow users to modify the files of another user by running scripts as the web server? Yes, don't let them run scripts as the web server user. Also, users may use the webserver to read private files of other users –  Damn Terminal Dec 8 '12 at 2:01
But that's the point of the web server. Users have access to the server so they can upload and publish their web pages. Thinking about it, it's probably impossible to prevent users from changing other users' files without running multiple instances of PHP/whatever (as a different web server user), isn't it? –  OH NO WHAT IS THIS Dec 8 '12 at 2:09
It's probably a good idea to run multiple instances of PHP/whatever, so that each runs under the user using it. However, you can give the web server rights to read and execute scripts, without giving it write permissions to them (751 where the user is the owner, and www-data belongs to the group). You can also prevent files readable by www-data to be viewable but other users. Don't run scripts as www-data and disable symlinking to other people's files, with disable_symlinks if_not_owner in nginx for example. –  Damn Terminal Dec 8 '12 at 2:15

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