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.

As per older questions, such as using mod_fcgid instead of mod_php and PHP as CGI or Apache Module? (and tangentially some other questions) I came to an understanding that running PHP as CGI or FastCGI would make my .php files be ran as the owner instead of the apache user (user that runs the Apache).

The phpinfo(); function states that Server API = CGI/FastCGI

However, when I test the running user it is still apache ie. <?php echo exec('whoami'); ?> returns apache.

I've also tried what Jeremy Bouse suggested in a question I've mentioned, but the PHP whoami still returns apache.


Should the fact that phpinfo's "Server API" equals "CGI/FastCGI" be adequate for regular users to run the php-files as the owner?

(Does it even indicate that PHP is not running with mod_php?)

Or are there some admin tasks still to be done or something that is probably misconfigured?

share|improve this question

2 Answers 2

Suexec can run cgi as users other than the apache user. If you want to run PHP like this you might also be interested in suPHP.

share|improve this answer

IMHO the (more recent and) best way to run PHP FastCGI is using PHP-FPM, which among the many options also permits to use different users for different websites.

From the official website:

Ability to start workers with different uid/gid/chroot/environment and different php.ini (replaces safe_mode)

But using FastCGI by itself is not enough to use the owner of the file (and there's no such thing as "automatically using the owner of the file": you have to actually configure it virtual host by virtual host (or as you wish).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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