You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marcus Merz <mm...@gmx.de> on 2010/02/23 22:47:58 UTC
Re: mod_fcgid: Problem serving binary content with Apache 2.2.13 - PHP 5.2.9
"Jeff Trawick" <tr...@gmail.com> schrieb im Newsbeitrag
news:cc67648e0910121343j7e922d94q1f96ee89cd897242@mail.gmail.com...
> On Mon, Oct 12, 2009 at 4:14 PM, Jeff Trawick <tr...@gmail.com> wrote:
>> On Sun, Oct 11, 2009 at 6:16 AM, Marcus Merz <mm...@gmx.de> 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
/etc/apache2/conf.d/mod_fcgid.conf)
The 'FcgidFixPathinfo 1' in /etc/apache2/conf.d/mod_fcgid.conf corresponds
to
---
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for
CGI. PHP's
; 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.
Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A
setting
; of zero causes PHP to behave as before. Default is 1. You should fix
your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
;cgi.fix_pathinfo=1
---
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
</Files>
---
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 mod_fcgid.so will be included in
/etc/apache2/sysconfig.d/loadmodule.conf.
In the order you included your modules above, mod_cgi.so will be implemented
before mod_fcgid.so 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
/srv/www/vhosts/<domain>/conf/
like this: /srv/www/vhosts/<domain>/conf/vhost.conf
---
<OtherImportantStuff>
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
'Include'.
/srv/www/vhosts/global.vhost.conf:
---
<IfModule mod_fcgid.c>
Alias /phpfcgidpath/ "/usr/bin/"
Action php-script /phpfcgidpath/php-cgi5
<Location /phpfcgidpath/>
SetHandler fcgid-script
Options +ExecCGI
</Location>
</IfModule>
---
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.
HTH.
Marcus
Re: mod_fcgid: Problem serving binary content with Apache 2.2.13 -
PHP 5.2.9
Posted by Jeff Trawick <tr...@gmail.com>.
On Tue, Feb 23, 2010 at 4:47 PM, Marcus Merz <mm...@gmx.de> wrote:
> Well, it's been a while but as i want other people to find a solution should
> they dig in old archives via Google,
Thanks for the good summary.