I am trying to replace SuPHP with FastCGI. 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
What am I doing wrong?
whoamijust shows you your current user, under which the current script is running.In ubuntu via fastcgi you run your scripts as
www-datauser, not as a user who owns that file. This is by design, it helps you to restrict web scripts from accessing the files they don't allowed to access. If you need to change this behavior, you need to change user apache is running somewhere in config files.On my system this is specified in
/etc/apacyhe2/envvarsby setting these two environment variables: