lighttpd - Run PHP script as the file's owner

What's the best way to set up lighttpd and FastCGI to run PHP scripts as the file's owner on Debian 6? I need to run separate WordPress blogs that are are able to write to their respective directories. I've already created the users, their web roots, and simple vhosts. Now what?

Thanks in advance.

2 Replies

By their owner, are you referring to files that are owned by different users on your Linode?

If so, there are two possibilities. One is to set the group ownership of the files to lighttpd's group, and set the user ownership of the files to whichever user that you want to own that site. For example, if lighttpd is assigned to group www-data, and you have a user called user1, the files for user1's site would still be owned by user1, so he can still access and modify his files directly, but the group ownership would be www-data. You would then allow the www-data group to have read and execute permissions on the files, and you would also allow write permission to www-data for the upload directory (if any) if you want to allow people connecting to the site to upload stuff. This will, of course, allow your users to add malicious php files to their web site directories, so you have to be careful.

The other way to do this is to set the user ownership to lighttpd's user, but to change the group instead. You can either have one group per user, and assign ownership of each site to their respective groups, or you can create a single group, for example wpusers, and add all your users to the wpusers group. Then you can change the group ownership of any wordpress directory to wpusers and assign the necessary read, write, and execute permissions that way. This method not only allows your users to upload malicious php files, they can mess with each other's sites if you use this method, so this method is less secure than setting the ownership on a per-user basis.

My usual approach is to start a separate set of PHP handlers for each user… basically, copy what you did to get it going the first time, but change the username and (socket or port) on each copy.

You'll probably want to decrease the number of children spawned by each instance, as well -- your RAM usage will be dictated by the total number of children across every instance.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct