FastCGI PHP in a shared environment?
I'm investigating the possibility of using the fastcgi version of PHP on a webhosting platform with a fairly large amount of customers sharing a single server. There are a couple of issues I'd like to hear your comments about before going further in the evaluation process.
After reading the fastcgi module documentation and the "Using PHP" document on SDN I conclude that it is possible to run a separate fastcgi process per virtual (or per obj.conf). This would seem to be the most secure solution and also enables per-customer configurations (separate php.ini files). Am I missing anything important here?
I guess running a separate PHP process per customer might lead to performance problems? All customers don't really use PHP at all so perhaps it would be wise not to enable it by default? This would decrease memory consumption but I bet most customers assume PHP service to be available "out of the box" without having to enable it manually somehow. It's a tough choice...
I'd be very grateful to hear any comments about PHP on Sun web servers in hosted environments. This doesn't seem to be the most common setup around (yeah, I know about that pesky little thing called Apache ;) but is it something we should try anyway?
[1262 byte] By [
HenriVa] at [2007-11-26 14:33:27]

# 1
Well ... I use it like so:
1) I have multiple obj.conf files - bare.obj.conf, bare-php.obj.conf, etc. I associate particular virtual servers with particular obj.conf files in the server.xml:
<object-file>obj/bare-php.obj.conf</object-file>
Adding PHP support for a VS is as easy as changing the obj.conf it's associated with int he server.xml and running the reconfig script.
2) In the bare-php.obj.conf file I configure the FastCGI engine:
Service fn=responder-fastcgi
app-path="/export/WS7/third-party/php/php_fcgi"
req-retry=5
type="*magnus-internal/fastcgi*"
app-env="PHPRC=/export/WS7/https-www.foo/config"
app-env="PHP_FCGI_CHILDREN=5"
app-env="PHP_FCGI_MAX_REQUEST=200"
min-procs=1
restart-interval=10
bucket="php-bucket"
rlimit_cpu=60
All my PHP enabled virtual servers (about a dozen or so) share a single FastCGI/PHP engine. I think it would be pretty trivial to use the predefined variables in WS.
Borrowing somewhat from Chris Elving's example at: http://blogs.sun.com/elving/entry/mass_virtual_hosting_in_7
Service fn=responder-fastcgi
app-path="/path/to/php/php_fcgi"
bind-path="$(lc($urlhost))"
req-retry=5
type="*magnus-internal/fastcgi*"
app-env="PHPRC=/path/to/users/$(lc($urlhost))/config"
app-env="PHP_FCGI_CHILDREN=5"
app-env="PHP_FCGI_MAX_REQUEST=200"
min-procs=1
restart-interval=10
bucket="php-bucket"
rlimit_cpu=60
I think this would use the same PHP binary for everyone (the one located at /path/to/php/php_fcgi), but each PHP process would have its own named Unix Domain Socket (UDS) named after the URL host. This would also pick up a unique php.ini file from a path on the file system (again, named after the URL host name).
But of course your mileage may vary, I haven't tried it, etc.