httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcus Merz" <>
Subject Re: mod_fcgid: Problem serving binary content with Apache 2.2.13 - PHP 5.2.9
Date Tue, 23 Feb 2010 21:47:58 GMT
"Jeff Trawick" <> schrieb im Newsbeitrag
> On Mon, Oct 12, 2009 at 4:14 PM, Jeff Trawick <> wrote:
>> On Sun, Oct 11, 2009 at 6:16 AM, Marcus Merz <> wrote:
>>> Is this issue solved in 2.3.4?
>> no
> BTW, I'm sorry I haven't followed up to your last couple of posts.  I
> should be honest with you:  All that Plesk-generated config and/or
> attempts to interject tweaks to that config makes my head explode.
> Maybe somebody else here has the time and will power to dig through
> it.


> Good luck!

Well, it's been a while but as i want other people to find a solution should 
they dig in old archives via Google, i wanted to share wiht you how i got 
around 'the wonderful world of Plesk' (no, i did not deinstall it...). 
Please acknowledge that i am neither a guru of Apache, mod_fcgid nor PHP. I 
simply want to help people who might face the same problem than i did about 
6 months ago. If you read this whole thread, then you know about the 
problems arising in certain -special- environments when you want to use 
mod_fcgid (i.e. active watermarking images like i did).

My current environment as of writing this is:
- suse-10.3-x86_64-plesk9
- Plesk 9.2.3
- Apache 2.2.4 with MPM-worker enabled
- PHP 5.2.9
- mod_fcgid 2.3.5 (with 'FcgidFixPathinfo 1' in 

The 'FcgidFixPathinfo 1' in /etc/apache2/conf.d/mod_fcgid.conf corresponds 
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for 
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to 
not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs. 
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A 
; of zero causes PHP to behave as before.  Default is 1.  You should fix 
your scripts

in /etc/php5/fastcgi/php.ini as cgi.fix_pathinfo=1 is the default. I mention 
it here because i refer to it later.

To avoid problems in an active watermark php script (caused by SetHandler 
and FCGIWrapper directives - please read the entire thread for details), 
this is what i did:

In Plesk, choose "PHP Support via CGI" from the dropdown menue in your 
<domain> "Web Hosting Setup".

This will add
        <Files ~ (\.php)>
                AddHandler php-script .php
                Options +ExecCGI
                allow from all

to your <domain>/conf/httpd.include file. Now, how do we get to use 
mod_fcgid then?

In /etc/sysconfig/apache2 you (hopefully) have:
APACHE_MODULES="<modules> cgi <moremodules> fcgid <evenmoremodules> suexec"

so will be included in 

In the order you included your modules above, will be implemented 
before and therefore /etc/apache2/conf.d/php_cgi.conf will be 
parsed before /etc/apache2/conf.d/mod_fcgid.conf. Do i make sense?

What does this mean?

In /etc/apache2/conf.d/php_cgi.conf we have
scriptAlias /phppath/ "/usr/bin/"
Action php-script /phppath/php-cgi5

(this was mentioned in here before). Actually this causes all PHP scripts to 
be parsed by mod_cgi. Hmm.... Fine. Let's add a vhost.conf in 

like this: /srv/www/vhosts/<domain>/conf/vhost.conf
Include /srv/www/vhosts/global.vhost.conf

What? This is because i want ALL domains to use PHP via mod_fcgid yet i do 
not want to change every vhost.conf manually which is why i use this 

<IfModule mod_fcgid.c>
        Alias /phpfcgidpath/ "/usr/bin/"
        Action php-script /phpfcgidpath/php-cgi5
        <Location /phpfcgidpath/>
                SetHandler fcgid-script
                Options +ExecCGI

Now, what do we do here? Well, we define an alias similiar like in 
/etc/apache2/conf.d/php_cgi.conf but via the Action statement and the 
following Location container, all Files ending (\.php) will now get parsed 
using mod_fcgid because of the
SetHandler fcgid-script

If you have set 'FcgidFixPathinfo 1' in 
/etc/apache2/conf.d/mod_fcgid.conf -as explained above- calling phpinfo() 
will tell you this
_SERVER["ORIG_SCRIPT_NAME"]   /phpfcgidpath/php-cgi5

which means, mod_fcgid has been used to parse the php file. This is what we 
wanted to achieve.

Instead of using a (global) vhost.conf file, you could probably put 
everything into /etc/apache2/conf.d/mod_fcgid.conf but this is like with 
Rome: There are more than one ways to achieve your goal. I just wrote about 
how I succeeded. Feel free to find your own way.


View raw message