0

I Have Apache2-Prefork running using mod_php and php 5.2.
And i also have php-fpm with php 5.3 running inside a chrooted environment (listening to an unix socket which would be reachable for apache)

Can someone please guide me how i have to configure a Virtualhost to use Fastcgi. (I've been searching the web for an example, but didnt find anything...)

And there is a point that confuses me...
if php runs across an include or fopen in which context will that be executed? Apaches or the chrooted environment? Can i still pass php directives over httpd.conf and .htaccess?

The whole FastCGI thing is still pretty confusing for me :) thanks in advance for any help!

Update: I'm pretty sure that i have to use mod_fastcgi and the FastCgiExternalServer directive. But i dont know how to tell apache that he sould do that only to .php files

2
  • why do you need the fastcgi php then?
    – cstamas
    Jun 17, 2011 at 21:31
  • so i can have php5.2 and php 5.3... and i dont want to run apache in the chrooted environment because i dont want to dedicate an ip to a php version...
    – Florian F
    Jun 17, 2011 at 21:49

2 Answers 2

1

In your Apache virtualhost directive, you configure a php5 handler,

AddHandler fcgid-script .php
FCGIWrapper /usr/lib/cgi-bin/php5 .php
Options ExecCGI

In that instance, the FCGIWrapper entry is the php5 cgi binary. Other examples suggest creating your own script and calling that, having that script set options and in turn calling php.

For example,

FCGIWrapper /usr/local/bin/php .php

If you go with a wrapper script you can set options in that, if you don't (i.e. the first example), then you can set options directly in the Apache config files,

<IfModule mod_fcgid.c>
 AddHandler    fcgid-script .fcgi
 FcgidConnectTimeout 20
 FcgidIOTimeout              60
 FcgidMaxRequestsPerProcess  400
 FcgidIdleTimeout            60
 FcgidMinProcessesPerClass   0
</IfModule>

That's pretty much it for a basic FastCGI config, some of it varies by distribution or if it's self compiled, but the above is the basic necessary stuff.

There appears to be quite an extensive FAQ on something very similar to your query here,

Apache + Chroot + FastCGI + PHP FAQ - http://www.seaoffire.net/fcgi-faq.html

4
  • I'm pretty sure that i have to use FastCgiExternalServer, but i cant find an Example of a vhost on the web...
    – Florian F
    Jun 18, 2011 at 17:54
  • Does the above not work, or do you know it won't work for a particular reason? Jun 18, 2011 at 18:02
  • It cant work because there is no fcgi handler that apache could call. php-fpm takes care of all that. There is just a socket listening for connections... (And i want to tell apace to use this socket for .php files of a specific virtualhost)
    – Florian F
    Jun 18, 2011 at 18:14
  • Okay so the doc entry for FastCgiExternalServer looks useful, have you tried it and does it not work? You should just use the AddHandler directive, and then include the FastCgiExternalServer detail. Some stuff here - cyberciti.biz/tips/… - and this might help - stackoverflow.com/questions/574690/… Jun 18, 2011 at 18:32
0

I wrote about this i my blog some time ago, with full examples and all. Here is the part about Apache + PHP FPM: http://blog.foaa.de/2010/11/php-apache-and-fastcgi-a-comprehensive-overview/#implementation.

If you scroll up, it also covers also a multitude of other (mostly outdated) ways implementing Apache + FastCGI. If nothing else, it might give you a deeper understanding on how FastCGI and Apache can communicate.

You must log in to answer this question.

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