TechSpider
A searchable, categorised online resourse for finding technical information and solutions to problems
Welcome! You are viewing the web category.
Below are the Apache and mod_fcgid: Problem serving binary content with Apache 2.2.13 - PHP 5.2.9 related pages
Custom Search
You can search the database for more Apache articles using the box below:
Custom Search

Apache Articles:



Thanks for the additional details.



I'm not aware of a connection between cgi.force_redirect and
PHP_Fix_Pathinfo_Enable. What do you know about that?


For the purposes of my recreate, I condensed this down to

AddHandler php-script .php

ScriptAlias /phppath/ /usr/bin/
Action php-script /phppath/php5-cgi


Allow from all



AddHandler php-script .php
Options +ExecCGI
Allow from all




For the purposes of my recreate, I condensed this down to


SetHandler fcgid-script
FCGIWrapper /usr/bin/php5-cgi .php
Options +ExecCGI
Allow from all


AddHandler php-script .php

Action php-script /phppath/php5-cgi


Allow from all



AddHandler php-script .php
Options +ExecCGI
Allow from all


As before, this only came close to working for me with cgi.fix_pathinfo=0.

With the CGI configuration in hand, then I tried to convert that directly to
FastCGI.

Theoretically we should just change the handler from cgi-script to
fcgid-script and it should work. But the CGI configuration uses ScriptAlias
as a short-cut for

Alias /phppath/ /usr/bin/

SetHandler cgi-script
Options +ExecCGI


When I use that expansion of ScriptAlias, and convert the cgi-script to
fcgid-script, I now get this for the FastCGI configuration:

AddHandler php-script .php

# ScriptAlias /phppath/ /usr/bin/
Alias /phppath/ /usr/bin/

SetHandler fcgid-script
Options +ExecCGI


Action php-script /phppath/php5-cgi


Allow from all



AddHandler php-script .php
Options +ExecCGI
Allow from all


That's the direct translation of the CGI configuration to a FastCGI
configuration. And the script works for me now via FastCGI, without
changing cgi.fix_pathinfo to 0. (I'm not setting PHP_Fix_PathInfo_Enable
either.)



AFAICT, if Plex was creating a mod_fcgid configuration that was an exact
translation from the mod_cgi configuration, it would work with mod_fcgid.



That is to be expected.

The CGI process is created for every request, so the Apache subprocess env
data is passed over as a native/OS environment variable when the process is
created.

The FastCGI process is started and intended to be run for many different
requests; the Apache subprocess env data is passed over on a socket with
the actual request.

The important stuff is populated in _SERVER[].


(shrug)

I looked at PHP itself and there is quite a lot of processing of such
variables at startup. That's where the answer is, but I don't know the
details. mod_fcgid and mod_cgi use the same core Apache function to set up
the subprocess env table. The only difference is that mod_fcgid changes
SCRIPT_NAME when PHP_Fix_PathInfo_Enable is set.


as expected



I didn't need the shebang line when I switched to the actual config you're
using for CGI.




Yes, it helps a lot.



No problem.

Please try translating the CGI config directly to FastCGI as noted above,
instead of using the Plesk-generated config, and let us know what happens.

Replace this bit


SetHandler fcgid-script
FCGIWrapper /usr/bin/php-cgi5 .php
Options +ExecCGI
Allow from all


with

Alias /phppath/ /usr/bin/

SetHandler fcgid-script
Options +ExecCGI



On Mon, Sep 21, 2009 at 2:24 PM, Marcus Merz
mail.com> schrieb im Newsbeitrag
r>

>What is your configuration to run modify.php as a CGI? =A0Do you add a<=
br>
>shebang line, or use something else?
>
>Here's my configuration:Thanks for =
the additional details.=A0

In my php.ini i have
; cgi.force_redirect is necessary to provide security running PHP as a CGI<=
br>
under
; most web servers. =A0Left undefined, PHP turns this on by default. =A0You=
can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; http://ph=
p.net/cgi.force-redirect
;cgi.force_redirect =3D 1
so it defaults to 1 which is why i set the same in mod_fcgid.conf via
'PHP_Fix_Pathinfo_Enable 1'.I'm not a=
ware of a connection between cgi.force_redirect and PHP_Fix_Pathinfo_Enable=
.=A0 What do you know about that?

a) Settings for using CGIFor the purposes of my recreate, I condensed this=
down to=A0=A0 AddHandler php-script .php=A0 ScriptAlias /p=
hppath/ /usr/bin/=A0 Action php-script /phppath/php5-cgi=A0 &lt=
;Directory /usr/bin/>
\.php)>=A0=A0=A0 AddHandler php-script .php=A0=A0=A0 Options +Ex=
ecCGI=A0=A0=A0 Allow from all=A0 </Files>
b) Settings for using FastCGI which is mod_fcgid is selected form Plesk:For the purposes of my recreate, I condensed =
this down to=A0 <Files ~ (\.php)>=A0=A0=A0 SetHandler fcg=
id-script=A0=A0=A0 FCGIWrapper /usr/bin/php5-cgi .php=A0=A0=A0 Opti=
ons +ExecCGI
ript .php=A0 Action php-script /phppath/php5-cgi=A0 <Dir=
ectory /usr/bin/>=A0=A0=A0 Allow from all=A0 </Directory><=
br>=A0 <Files ~ (\.php)>
e close to working for me with cgi.fix_pathinfo=3D0.With the CGI co=
nfiguration in hand, then I tried to convert that directly to FastCGI.Theoretically we should just change the handler from cgi-script to fcgi=
d-script and it should work.=A0 But the CGI configuration uses ScriptAlias =
as a short-cut forAlias /phppath/ /usr/bin/=A0 <Location /ph=
ppath/>
ocation>When I use that expansion of ScriptAlias, and convert th=
e cgi-script to fcgid-script, I now get this for the FastCGI configuration:=
=A0 AddHandler php-script .php=A0 # ScriptAlias /phppath/ /usr/bin/=A0 Alias /phppath/ /usr/bin/<=
br>=A0 <Location /phppath/>=A0=A0=A0 SetHandler fcgid-script=
cript /phppath/php5-cgi=A0 <Directory /usr/bin/>=A0=A0=A0 Allow from all=A0 <=
/Directory>=A0 <Files ~ (\.php)>=A0=A0=A0 AddHandler p=
hp-script .php=A0=A0=A0 Options +ExecCGI=A0=A0=A0 Allow from all
php files get parsed either with module mod_cgi.so or mod_fcgid.so (which i=
s
a symlink to the 2.3.1 version i compiled) and both times with the same
binary /usr/bin/php-cgi5.
At least that is my understanding.AFAICT, if Plex was creating a mod_fcgid configur=
ation that was an exact translation from the mod_cgi configuration, it woul=
d work with mod_fcgid.=A0


There is another difference looking at phpinfo():
Using mod_fcgid the only Environment variable i see is PATH. Using mod_cgi<=
br>
there are a whole lot more Envrionment variables. To my understanding
variables shown under 'Environment' are Apache ENV variables.=
blockquote>That is to be expected.The CGI process is creat=
ed for every request, so the Apache subprocess env data is passed over as a=
native/OS environment variable when the process is created.The FastCGI process is started and intended to be run for many differen=
t requests;=A0 the Apache subprocess env data is passed over on a socket wi=
th the actual request.The important stuff is populated in _SERVER[]=
.

phpinfo() from CGI via http://www.domain.tld/admin/phpinfo.php:
Environment
Variable =A0 =A0 =A0 =A0Value
PATH =A0 =A0 =A0 =A0/usr/local/bin:/usr/bin:/bin
REDIRECT_STATUS =A0 =A0200
1.3)
Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729)
text/html,application/xhtml+xml,application/xml;q=3D0.9,*/*;q=3D0.8
SERVER_SOFTWARE =A0 =A0Apache/2.2.13 (Linux/SUSE)
SERVER_NAME =A0 =A0domain.tld
SERVER_ADDR =A0 =A0<IP>
SERVER_PORT =A0 =A080
REMOTE_ADDR =A0 =A0<another IP>
DOCUMENT_ROOT =A0 =A0/srv/www/vhosts/domain.tld/httpdocs
SERVER_ADMIN =A0 =A0***
SCRIPT_FILENAME =A0 =A0/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.ph=
p
REMOTE_PORT =A0 =A058740
REDIRECT_URL =A0 =A0/admin/phpinfo.php
GATEWAY_INTERFACE =A0 =A0CGI/1.1
SERVER_PROTOCOL =A0 =A0HTTP/1.1
REQUEST_METHOD =A0 =A0GET
QUERY_STRING =A0 =A0no value
REQUEST_URI =A0 =A0/admin/phpinfo.php
SCRIPT_NAME =A0 =A0/admin/phpinfo.php
ORIG_SCRIPT_FILENAME =A0 =A0/usr/bin/php-cgi5
ORIG_PATH_INFO =A0 =A0/admin/phpinfo.php
ORIG_PATH_TRANSLATED
/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php
ORIG_SCRIPT_NAME =A0 =A0/phppath/php-cgi5
PHP Variables
Variable =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =

_SERVER["PATH"] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
_SERVER["REDIRECT_STATUS"] =A0 =A0 =A0 =A0200
_SERVER["HTTP_HOST"] =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0www.d=
omain.tld
_SERVER["HTTP_USER_AGENT"] =A0 =A0Mozilla/5.0 (Windows; U; Window=
s NT 5.1; de;
rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729)
_SERVER["HTTP_ACCEPT"]
text/html,application/xhtml+xml,application/xml;q=3D0.9,*/*;q=3D0.8
_SERVER["HTTP_ACCEPT_LANGUAGE"] =A0 =A0de
_SERVER["HTTP_ACCEPT_ENCODING"] =A0 =A0gzip
_SERVER["HTTP_ACCEPT_CHARSET"] =A0 =A0ISO-8859-1,utf-8;q=3D0.7,*;=
q=3D0.7
_SERVER["HTTP_KEEP_ALIVE"] =A0 =A0300
_SERVER["HTTP_CONNECTION"] =A0 =A0keep-alive
_SERVER["SERVER_SOFTWARE"] =A0 =A0Apache/2.2.13 (Linux/SUSE)
_SERVER["SERVER_NAME"] =A0 =A0domain.tld
_SERVER["SERVER_ADDR"] =A0 =A0<IP>
_SERVER["SERVER_PORT"] =A0 =A080
_SERVER["REMOTE_ADDR"] =A0 =A0<another IP>
_SERVER["DOCUMENT_ROOT"] =A0 =A0/srv/www/vhosts/domain.tld/httpdo=
cs
_SERVER["SERVER_ADMIN"] =A0 =A0***
_SERVER["SCRIPT_FILENAME"]
/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php
_SERVER["REMOTE_PORT"] =A0 =A058740
_SERVER["REDIRECT_URL"] =A0 =A0/admin/phpinfo.php
_SERVER["GATEWAY_INTERFACE"] =A0 =A0CGI/1.1
_SERVER["SERVER_PROTOCOL"] =A0 =A0HTTP/1.1
_SERVER["REQUEST_METHOD"] =A0 =A0GET
_SERVER["QUERY_STRING"] =A0 =A0no value
_SERVER["REQUEST_URI"] =A0 =A0/admin/phpinfo.php
_SERVER["SCRIPT_NAME"] =A0 =A0/admin/phpinfo.php
_SERVER["ORIG_SCRIPT_FILENAME"] =A0 =A0/usr/bin/php-cgi5
_SERVER["ORIG_PATH_INFO"] =A0 =A0/admin/phpinfo.php
_SERVER["ORIG_PATH_TRANSLATED"]
/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php
_SERVER["ORIG_SCRIPT_NAME"] =A0 =A0/phppath/php-cgi5
_SERVER["PHP_SELF"] =A0 =A0/admin/phpinfo.php
_SERVER["REQUEST_TIME"] =A0 =A01253555191
_SERVER["argv"] =A0 =A0Array
(
)
_SERVER["argc"] =A0 =A00
_ENV["PATH"] =A0 =A0/usr/local/bin:/usr/bin:/bin
_ENV["REDIRECT_STATUS"] =A0 =A0200
_ENV["HTTP_HOST"] =A0 =A0www.domain.tld
_ENV["HTTP_USER_AGENT"] =A0 =A0Mozilla/5.0 (Windows; U; Windows N=
T 5.1; de;
rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729)
_ENV["HTTP_ACCEPT"]
text/html,application/xhtml+xml,application/xml;q=3D0.9,*/*;q=3D0.8
_ENV["HTTP_ACCEPT_LANGUAGE"] =A0 =A0de
_ENV["HTTP_ACCEPT_ENCODING"] =A0 =A0gzip
_ENV["HTTP_ACCEPT_CHARSET"] =A0 =A0ISO-8859-1,utf-8;q=3D0.7,*;q=
_ENV["HTTP_KEEP_ALIVE"] =A0 =A0300
_ENV["HTTP_CONNECTION"] =A0 =A0keep-alive
_ENV["SERVER_SOFTWARE"] =A0 =A0Apache/2.2.13 (Linux/SUSE)
_ENV["SERVER_NAME"] =A0 =A0domain.tld
_ENV["SERVER_ADDR"] =A0 =A0<IP>
_ENV["SERVER_PORT"]80
_ENV["REMOTE_ADDR"] =A0 =A0<another IP>
_ENV["DOCUMENT_ROOT"] =A0 =A0/srv/www/vhosts/domain.tld/httpdocs<=
br>
_ENV["SERVER_ADMIN"] =A0 =A0***
_ENV["SCRIPT_FILENAME"]
/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php
_ENV["REMOTE_PORT"] =A0 =A058740
_ENV["REDIRECT_URL"] =A0 =A0/admin/phpinfo.php
_ENV["GATEWAY_INTERFACE"] =A0 =A0CGI/1.1
_ENV["SERVER_PROTOCOL"] =A0 =A0HTTP/1.1
_ENV["REQUEST_METHOD"] =A0 =A0GET
_ENV["QUERY_STRING"] =A0 =A0no value
_ENV["REQUEST_URI"] =A0 =A0/admin/phpinfo.php
_ENV["SCRIPT_NAME"] =A0 =A0/admin/phpinfo.php
_ENV["ORIG_SCRIPT_FILENAME"] =A0 =A0/usr/bin/php-cgi5
_ENV["ORIG_PATH_INFO"] =A0 =A0/admin/phpinfo.php
_ENV["ORIG_PATH_TRANSLATED"]
/srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php
_ENV["ORIG_SCRIPT_NAME"] =A0 =A0/phppath/php-cgi5
phpinfo() from mod_fcgid - via http://domain.tld/phpinfo.php
Environment
Variable =A0 =A0 =A0 =A0 =A0 =A0Value
PATH =A0 =A0 =A0 =A0 =A0 =A0 =A0 /usr/local/bin:/usr/bin:/bin
PHP Variables
Variable =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Value
_SERVER["PATH"] =A0 =A0/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/b=
in
_SERVER["FCGI_ROLE"] =A0 =A0RESPONDER
_SERVER["HTTP_HOST"] =A0 =A0domain.tld
_SERVER["HTTP_USER_AGENT"] =A0 =A0Mozilla/5.0 (Windows; U; Window=
s NT 5.1; de;
rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729)
_SERVER["HTTP_ACCEPT"]
text/html,application/xhtml+xml,application/xml;q=3D0.9,*/*;q=3D0.8
_SERVER["HTTP_ACCEPT_LANGUAGE"] =A0 =A0de
_SERVER["HTTP_ACCEPT_ENCODING"] =A0 =A0gzip
_SERVER["HTTP_ACCEPT_CHARSET"] =A0 =A0ISO-8859-1,utf-8;q=3D0.7,*;=
q=3D0.7
_SERVER["HTTP_CONNECTION"] =A0 =A0close
_SERVER["SERVER_SIGNATURE"] =A0 =A0<address>Apache/2.2.13 (=
Linux/SUSE) Server at
domain.tld Port 80</address>
_SERVER["SERVER_SOFTWARE"] =A0 =A0Apache/2.2.13 (Linux/SUSE)
_SERVER["SERVER_NAME"] =A0 =A0domain.tld
_SERVER["SERVER_ADDR"] =A0 =A0<IP>
_SERVER["SERVER_PORT"] =A0 =A080
_SERVER["REMOTE_ADDR"] =A0 =A0<another IP>
_SERVER["DOCUMENT_ROOT"] =A0 =A0/srv/www/vhosts/domain.tld/httpdo=
cs
_SERVER["SERVER_ADMIN"] =A0 =A0***
_SERVER["SCRIPT_FILENAME"]
/srv/www/vhosts/domain.tld/httpdocs/phpinfo.php
_SERVER["REMOTE_PORT"] =A0 =A058860
_SERVER["GATEWAY_INTERFACE"] =A0 =A0CGI/1.1
_SERVER["SERVER_PROTOCOL"] =A0 =A0HTTP/1.1
_SERVER["REQUEST_METHOD"] =A0 =A0GET
_SERVER["QUERY_STRING"] =A0 =A0no value
_SERVER["REQUEST_URI"] =A0 =A0/phpinfo.php
_SERVER["SCRIPT_NAME"] =A0 =A0/phpinfo.php
_SERVER["PHP_SELF"] =A0 =A0/phpinfo.php
_SERVER["REQUEST_TIME"] =A0 =A01253554382
_SERVER["argv"] =A0 =A0Array
(
)
_SERVER["argc"] =A0 =A00
_ENV["PATH"] =A0 =A0/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin<=
br>
_ENV["FCGI_ROLE"] =A0 =A0RESPONDER
_ENV["HTTP_HOST"] =A0 =A0domain.tld
_ENV["HTTP_USER_AGENT"] =A0 =A0Mozilla/5.0 (Windows; U; Windows N=
T 5.1; de;
rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729)
_ENV["HTTP_ACCEPT"]
text/html,application/xhtml+xml,application/xml;q=3D0.9,*/*;q=3D0.8
_ENV["HTTP_ACCEPT_LANGUAGE"] =A0 =A0de
_ENV["HTTP_ACCEPT_ENCODING"] =A0 =A0gzip
_ENV["HTTP_ACCEPT_CHARSET"] =A0 =A0ISO-8859-1,utf-8;q=3D0.7,*;q=
_ENV["HTTP_CONNECTION"] =A0 =A0close
_ENV["SERVER_SIGNATURE"] =A0 =A0<address>Apache/2.2.13 (Lin=
ux/SUSE) Server at
domain.tld Port 80</address>
_ENV["SERVER_SOFTWARE"] =A0 =A0Apache/2.2.13 (Linux/SUSE)
_ENV["SERVER_NAME"] =A0 =A0domain.tld
_ENV["SERVER_ADDR"] =A0 =A0<IP>
_ENV["SERVER_PORT"] =A0 =A080
_ENV["REMOTE_ADDR"] =A0 =A0<another IP>
_ENV["DOCUMENT_ROOT"] =A0 =A0/srv/www/vhosts/domain.tld/httpdocs<=
br>
_ENV["SERVER_ADMIN"]***
_ENV["SCRIPT_FILENAME"] =A0 =A0/srv/www/vhosts/domain.tld/httpdoc=
s/phpinfo.php
_ENV["REMOTE_PORT"] =A0 =A058860
_ENV["GATEWAY_INTERFACE"] =A0 =A0CGI/1.1
_ENV["SERVER_PROTOCOL"] =A0 =A0HTTP/1.1
_ENV["REQUEST_METHOD"] =A0 =A0GET
_ENV["QUERY_STRING"] =A0 =A0no value
_ENV["REQUEST_URI"] =A0 =A0/phpinfo.php
_ENV["SCRIPT_NAME"] =A0 =A0/phpinfo.php
Both use the same php.ini from /etc/php5/fastcgi/php.ini.
At least these variables are missing from mod_fcgid's phpinfo():
_SERVER["REDIRECT_STATUS"]
_SERVER["ORIG_SCRIPT_FILENAME"]
_SERVER["ORIG_PATH_INFO"]
_SERVER["ORIG_PATH_TRANSLATED"]
_SERVER["ORIG_SCRIPT_NAME"](shrug)I looked at PHP itself and there i=
s quite a lot of processing of such variables at startup.=A0 That's whe=
re the answer is, but I don't know the details.=A0 mod_fcgid and mod_cg=
i use the same core Apache function to set up the subprocess env table.=A0 =
The only difference is that mod_fcgid changes SCRIPT_NAME when PHP_Fix_Path=
Info_Enable is set.
lid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
and of course the same _ENV variables as there is only _ENV["PATH&quot=
;] set
anyway with mod_fcgid.as expected=A0

Concernig the shebang line in modify.php: From what i wrote, you can see,
that i do not put anything in modify.php. I use the script as written in my=

first post. It will be parsed depending on the httpd.include file from abov=
e
(which is built from Plesk each time you change the configuraition there
Via the AddHandler and Action directive the image with watermark is shown
when using cfg-fcgi and PHP tries to parse the image when using mod_fcgid.<=
br>I didn't need the shebang line when I switched=
to the actual config you're using for CGI. =A0=


I hope this clearifies the situation a lot more instead of causing even mor=
e
confusion.Yes, it helps a lot.=A0

I was happy to give you even more information if you told me what you need.=

I would really like to get this solved (and apologies concerning the
formatting of these variables).No problem.Replace this bit<Files ~ (\.php)>=A0=A0=A0 SetHandler=
fcgid-script=A0=A0=A0 FCGIWrapper /usr/bin/php-cgi5 .php=A0=A0=A0 =
Options +ExecCGI=A0=A0=A0 Allow from all=A0 </Files>w=
ith Alias /phppath/ /usr/bin/
Article list Name Date
Click Here Marcus Merz 2009-09-19 07:48:56
Click Here Jeff Trawick 2009-09-20 01:42:58
Click Here Marcus Merz 2009-09-20 16:30:02
Click Here Jeff Trawick 2009-09-21 15:27:13
Click Here Marcus Merz 2009-09-21 18:24:34
Click Here Marcus Merz 2009-09-21 18:40:34
Currently Viewing : This ArticleJeff Trawick2009-09-21 21:55:59
Click Here Marcus Merz 2009-09-22 05:21:49
Click Here Marcus Merz 2009-09-22 18:07:12
Click Here Marcus Merz 2009-09-23 18:33:17
Click Here Marcus Merz 2009-10-11 10:16:30
Click Here Jeff Trawick 2009-10-12 20:14:40
Click Here Jeff Trawick 2009-10-12 20:43:56
Click Here Marcus Merz 2010-02-23 21:47:58
Click Here Jeff Trawick 2010-02-23 23:57:30


Copyright Techspider V0.81   |   Techspider Sitemap