0

I am trying to setup FastCGI and PHP-FPM so that a php file can be executed as the owner of the file. I am trying to replace SuPHP with FastCGI and fpm. Earlier, I had folders with different owners and groups. Each group had www-data as a member as well. When any php file was run using the browser, it was run as the owner of the file. So if a file was owned by user A (Group A - www-data and A as members), it was executed as user A

shell_exec('whoami') => return A

Now, I installed fastcgi and have configured it to run PHP files.

Here is my php5-fpm.conf file

<IfModule mod_fastcgi.c>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
        </IfModule>

My issue is, now when I run the same file which is owned by A,

shell_exec('whoami') => return www-data

Is it possible to run the php file as the owner using FastCGI and fpm (like with suPHP)? If so, how do I do that?

1 Answer 1

0

Yes, this is perfectly possible. User and group can be set in the FPM pool config (directives user and group).

Check

http://php.net/manual/en/install.fpm.configuration.php

for more information.

3
  • I think you misunderstood my question. When I say whether it is possible to run the php as the owner of the file, I meant similar to what suPHP does and without actually setting up virtual hosting. Basically, I have only 1 conf file for fpm which lists user and group as www-data but when running php files I want the owner of the file to be the user who runs it. (Exactly what suPHP does)
    – Kshitiz
    Sep 5, 2014 at 12:46
  • Ok, as far as I know, this is not possible. You will have to set the user and group on a per-pool basis.
    – etagenklo
    Sep 5, 2014 at 14:13
  • yeah I searched a lot and wasn't able to find anything relevant. Reverting back to suPHP and have new problems with Apache 2.4 serverfault.com/questions/626511/…
    – Kshitiz
    Sep 5, 2014 at 14:16

You must log in to answer this question.

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