On Mon, Sep 21, 2009 at 2:24 PM, Marcus Merz <[email protected]> wrote: > > "Jeff Trawick" <[email protected]> schrieb im Newsbeitrag > news:[email protected]... > > >What is your configuration to run modify.php as a CGI? Do you add a > >shebang line, or use something else? > > > >Here's my configuration: >
Thanks for the additional details. > > In my php.ini i have > > ; cgi.force_redirect is necessary to provide security running PHP as a CGI > under > ; most web servers. Left undefined, PHP turns this on by default. You can > ; turn it off here AT YOUR OWN RISK > ; **You CAN safely turn this off for IIS, in fact, you MUST.** > ; http://php.net/cgi.force-redirect > ;cgi.force_redirect = 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 aware of a connection between cgi.force_redirect and PHP_Fix_Pathinfo_Enable. What do you know about that? > a) Settings for using CGI > > 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 <Directory /usr/bin/> Allow from all </Directory> <Files ~ (\.php)> AddHandler php-script .php Options +ExecCGI Allow from all </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 <Files ~ (\.php)> SetHandler fcgid-script FCGIWrapper /usr/bin/php5-cgi .php Options +ExecCGI Allow from all </Files> AddHandler php-script .php Action php-script /phppath/php5-cgi <Directory /usr/bin/> Allow from all </Directory> <Files ~ (\.php)> AddHandler php-script .php Options +ExecCGI Allow from all </Files> 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/ <Location /phppath/> SetHandler cgi-script Options +ExecCGI </Location> 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/ <Location /phppath/> SetHandler fcgid-script Options +ExecCGI </Location> Action php-script /phppath/php5-cgi <Directory /usr/bin/> Allow from all </Directory> <Files ~ (\.php)> AddHandler php-script .php Options +ExecCGI Allow from all </Files> 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.) > So depending on what i set in Plesk the httpd.include file gets changed and > php files get parsed either with module mod_cgi.so or mod_fcgid.so (which > is > 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 configuration that was an exact translation from the mod_cgi configuration, it would work with mod_fcgid. > > There is another difference looking at phpinfo(): > > Using mod_fcgid the only Environment variable i see is PATH. Using mod_cgi > there are a whole lot more Envrionment variables. To my understanding > variables shown under 'Environment' are Apache ENV variables. > 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[]. > > phpinfo() from CGI via http://www.domain.tld/admin/phpinfo.php: > > Environment > Variable Value > PATH /usr/local/bin:/usr/bin:/bin > REDIRECT_STATUS 200 > HTTP_HOST www.domain.tld > HTTP_USER_AGENT Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.3) > Gecko/20090824 Firefox/3.5.3 GTB5 (.NET CLR 3.5.30729) > HTTP_ACCEPT > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 > HTTP_ACCEPT_LANGUAGE de > HTTP_ACCEPT_ENCODING gzip > HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7 > HTTP_KEEP_ALIVE 300 > HTTP_CONNECTION keep-alive > HTTP_COOKIE *** > SERVER_SOFTWARE Apache/2.2.13 (Linux/SUSE) > SERVER_NAME domain.tld > SERVER_ADDR <IP> > SERVER_PORT 80 > REMOTE_ADDR <another IP> > DOCUMENT_ROOT /srv/www/vhosts/domain.tld/httpdocs > SERVER_ADMIN *** > SCRIPT_FILENAME /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > REMOTE_PORT 58740 > REDIRECT_URL /admin/phpinfo.php > GATEWAY_INTERFACE CGI/1.1 > SERVER_PROTOCOL HTTP/1.1 > REQUEST_METHOD GET > QUERY_STRING no value > REQUEST_URI /admin/phpinfo.php > SCRIPT_NAME /admin/phpinfo.php > ORIG_SCRIPT_FILENAME /usr/bin/php-cgi5 > ORIG_PATH_INFO /admin/phpinfo.php > ORIG_PATH_TRANSLATED > /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > ORIG_SCRIPT_NAME /phppath/php-cgi5 > > > PHP Variables > Variable Value > > _SERVER["PATH"] /usr/local/bin:/usr/bin:/bin > _SERVER["REDIRECT_STATUS"] 200 > _SERVER["HTTP_HOST"] www.domain.tld > _SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (Windows; U; Windows 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=0.9,*/*;q=0.8 > _SERVER["HTTP_ACCEPT_LANGUAGE"] de > _SERVER["HTTP_ACCEPT_ENCODING"] gzip > _SERVER["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7 > _SERVER["HTTP_KEEP_ALIVE"] 300 > _SERVER["HTTP_CONNECTION"] keep-alive > _SERVER["SERVER_SOFTWARE"] Apache/2.2.13 (Linux/SUSE) > _SERVER["SERVER_NAME"] domain.tld > _SERVER["SERVER_ADDR"] <IP> > _SERVER["SERVER_PORT"] 80 > _SERVER["REMOTE_ADDR"] <another IP> > _SERVER["DOCUMENT_ROOT"] /srv/www/vhosts/domain.tld/httpdocs > _SERVER["SERVER_ADMIN"] *** > _SERVER["SCRIPT_FILENAME"] > /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > _SERVER["REMOTE_PORT"] 58740 > _SERVER["REDIRECT_URL"] /admin/phpinfo.php > _SERVER["GATEWAY_INTERFACE"] CGI/1.1 > _SERVER["SERVER_PROTOCOL"] HTTP/1.1 > _SERVER["REQUEST_METHOD"] GET > _SERVER["QUERY_STRING"] no value > _SERVER["REQUEST_URI"] /admin/phpinfo.php > _SERVER["SCRIPT_NAME"] /admin/phpinfo.php > _SERVER["ORIG_SCRIPT_FILENAME"] /usr/bin/php-cgi5 > _SERVER["ORIG_PATH_INFO"] /admin/phpinfo.php > _SERVER["ORIG_PATH_TRANSLATED"] > /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > _SERVER["ORIG_SCRIPT_NAME"] /phppath/php-cgi5 > _SERVER["PHP_SELF"] /admin/phpinfo.php > _SERVER["REQUEST_TIME"] 1253555191 > _SERVER["argv"] Array > ( > ) > > > _SERVER["argc"] 0 > _ENV["PATH"] /usr/local/bin:/usr/bin:/bin > _ENV["REDIRECT_STATUS"] 200 > _ENV["HTTP_HOST"] www.domain.tld > _ENV["HTTP_USER_AGENT"] Mozilla/5.0 (Windows; U; Windows NT 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=0.9,*/*;q=0.8 > _ENV["HTTP_ACCEPT_LANGUAGE"] de > _ENV["HTTP_ACCEPT_ENCODING"] gzip > _ENV["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7 > _ENV["HTTP_KEEP_ALIVE"] 300 > _ENV["HTTP_CONNECTION"] keep-alive > _ENV["SERVER_SOFTWARE"] Apache/2.2.13 (Linux/SUSE) > _ENV["SERVER_NAME"] domain.tld > _ENV["SERVER_ADDR"] <IP> > _ENV["SERVER_PORT"]80 > _ENV["REMOTE_ADDR"] <another IP> > _ENV["DOCUMENT_ROOT"] /srv/www/vhosts/domain.tld/httpdocs > _ENV["SERVER_ADMIN"] *** > _ENV["SCRIPT_FILENAME"] > /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > _ENV["REMOTE_PORT"] 58740 > _ENV["REDIRECT_URL"] /admin/phpinfo.php > _ENV["GATEWAY_INTERFACE"] CGI/1.1 > _ENV["SERVER_PROTOCOL"] HTTP/1.1 > _ENV["REQUEST_METHOD"] GET > _ENV["QUERY_STRING"] no value > _ENV["REQUEST_URI"] /admin/phpinfo.php > _ENV["SCRIPT_NAME"] /admin/phpinfo.php > _ENV["ORIG_SCRIPT_FILENAME"] /usr/bin/php-cgi5 > _ENV["ORIG_PATH_INFO"] /admin/phpinfo.php > _ENV["ORIG_PATH_TRANSLATED"] > /srv/www/vhosts/domain.tld/httpdocs/admin/phpinfo.php > _ENV["ORIG_SCRIPT_NAME"] /phppath/php-cgi5 > > > > > phpinfo() from mod_fcgid - via http://domain.tld/phpinfo.php > > Environment > Variable Value > PATH /usr/local/bin:/usr/bin:/bin > > PHP Variables > Variable Value > _SERVER["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin > _SERVER["FCGI_ROLE"] RESPONDER > _SERVER["HTTP_HOST"] domain.tld > _SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (Windows; U; Windows 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=0.9,*/*;q=0.8 > _SERVER["HTTP_ACCEPT_LANGUAGE"] de > _SERVER["HTTP_ACCEPT_ENCODING"] gzip > _SERVER["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7 > _SERVER["HTTP_CONNECTION"] close > _SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.13 (Linux/SUSE) Server > at > domain.tld Port 80</address> > _SERVER["SERVER_SOFTWARE"] Apache/2.2.13 (Linux/SUSE) > _SERVER["SERVER_NAME"] domain.tld > _SERVER["SERVER_ADDR"] <IP> > _SERVER["SERVER_PORT"] 80 > _SERVER["REMOTE_ADDR"] <another IP> > _SERVER["DOCUMENT_ROOT"] /srv/www/vhosts/domain.tld/httpdocs > _SERVER["SERVER_ADMIN"] *** > _SERVER["SCRIPT_FILENAME"] > /srv/www/vhosts/domain.tld/httpdocs/phpinfo.php > _SERVER["REMOTE_PORT"] 58860 > _SERVER["GATEWAY_INTERFACE"] CGI/1.1 > _SERVER["SERVER_PROTOCOL"] HTTP/1.1 > _SERVER["REQUEST_METHOD"] GET > _SERVER["QUERY_STRING"] no value > _SERVER["REQUEST_URI"] /phpinfo.php > _SERVER["SCRIPT_NAME"] /phpinfo.php > _SERVER["PHP_SELF"] /phpinfo.php > _SERVER["REQUEST_TIME"] 1253554382 > _SERVER["argv"] Array > ( > ) > > > _SERVER["argc"] 0 > _ENV["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin > _ENV["FCGI_ROLE"] RESPONDER > _ENV["HTTP_HOST"] domain.tld > _ENV["HTTP_USER_AGENT"] Mozilla/5.0 (Windows; U; Windows NT 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=0.9,*/*;q=0.8 > _ENV["HTTP_ACCEPT_LANGUAGE"] de > _ENV["HTTP_ACCEPT_ENCODING"] gzip > _ENV["HTTP_ACCEPT_CHARSET"] ISO-8859-1,utf-8;q=0.7,*;q=0.7 > _ENV["HTTP_CONNECTION"] close > _ENV["SERVER_SIGNATURE"] <address>Apache/2.2.13 (Linux/SUSE) Server at > domain.tld Port 80</address> > _ENV["SERVER_SOFTWARE"] Apache/2.2.13 (Linux/SUSE) > _ENV["SERVER_NAME"] domain.tld > _ENV["SERVER_ADDR"] <IP> > _ENV["SERVER_PORT"] 80 > _ENV["REMOTE_ADDR"] <another IP> > _ENV["DOCUMENT_ROOT"] /srv/www/vhosts/domain.tld/httpdocs > _ENV["SERVER_ADMIN"]*** > _ENV["SCRIPT_FILENAME"] /srv/www/vhosts/domain.tld/httpdocs/phpinfo.php > _ENV["REMOTE_PORT"] 58860 > _ENV["GATEWAY_INTERFACE"] CGI/1.1 > _ENV["SERVER_PROTOCOL"] HTTP/1.1 > _ENV["REQUEST_METHOD"] GET > _ENV["QUERY_STRING"] no value > _ENV["REQUEST_URI"] /phpinfo.php > _ENV["SCRIPT_NAME"] /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 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. > and of course the same _ENV variables as there is only _ENV["PATH"] set > anyway with mod_fcgid. > > as expected > > > 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 > above > (which is built from Plesk each time you change the configuraition there > from 'FastCGI-Application' to 'CGI-Application' using the same .htaccess. > 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. > I didn't need the shebang line when I switched to the actual config you're using for CGI. > > I hope this clearifies the situation a lot more instead of causing even > more > confusion. > Yes, it helps a lot. > > 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. 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 <Files ~ (\.php)> SetHandler fcgid-script FCGIWrapper /usr/bin/php-cgi5 .php Options +ExecCGI Allow from all </Files> with Alias /phppath/ /usr/bin/ <Location /phppath/> SetHandler fcgid-script Options +ExecCGI </Location>
