Search code examples
phpfile-permissionsuser-accounts

Is it possible to use server side PHP scripts for Specific Linux user accounts


I choose not to post this on SeverFault b/c that site seems to be only for the most experienced server administrators. I started a discussion about it over at MetaStackOverflow

A while back I asked a question about what user you log in as when you execute server side PHP scripts (in my case, from javascript/HTML) and it is www-data.

I wanted to know if it was possible to connect as another user, ie. John.Smith instead. I want to set up a website where permissions of pictures/images/text...are taken from linux instead of the SQL database (or if they are in the database, then they reflect the actual linux file permissions.

If this is impossible, or the equivalent to server heresy, are there any workarounds, like adding every user to group www-data by default.


Solution

  • Since no one suggested this in the form of an answer, I'll go ahead and do it. The solution is suPHP.

    suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.