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.

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

share|improve this question
    
why do you need the fastcgi php then? –  cstamas Jun 17 '11 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 Fida Jun 17 '11 at 21:49
add comment

2 Answers

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

share|improve this answer
    
I'm pretty sure that i have to use FastCgiExternalServer, but i cant find an Example of a vhost on the web... –  Florian Fida Jun 18 '11 at 17:54
    
Does the above not work, or do you know it won't work for a particular reason? –  EightBitTony Jun 18 '11 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 Fida Jun 18 '11 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/… –  EightBitTony Jun 18 '11 at 18:32
add comment

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.

share|improve this answer
add comment

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.