"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:
>
>LoadModule fcgid_module modules/mod_fcgid.so
>
><Directory /home/trawick/inst/22/htdocs/wtmrk/>
>  Allow from all
>  AddHandler wtmrk jpg
>  Action     wtmrk /modify.php
></Directory>
>
><Files ~ (\.php)>
>
>  <IfModule mod_fcgid.c>
>    SetHandler fcgid-script
>    FCGIWrapper /usr/bin/php5-cgi .php
>  </IfModule>
>
>  <IfModule !mod_fcgid.c>
>    SetHandler cgi-script
>  </IfModule>
>
>  Options +ExecCGI
>  Allow from all
></Files>
>
>I comment out the LoadModule directive to switch to CGI.  I had to add a 
>shebang line to the top of modify.php.
>

I use Plesk 9.2.1 (on OpenSUSE 10.3) to define my domains/virtual hosts. For 
PHP I can choose between 'Apache Module', 'FastCGI-Application' and 
'CGI-Application'. I will skip the settings for Apache Module here. 
Depending on what you select, Plesk does adjust the corresponding 
httpd.include for the respective domain (i.e. virtual host). Furthermore i 
use support for perl and python. The httpd.include sits in 
/srv/www/vhosts/domain.tld/conf and is included from 
/etc/apache2/conf.d/zz010_psa_httpd.conf (which gets included from 
/etc/apache2/httpd.conf).


General configuration from /etc/apache2/sysconfig.d/loadmodule.conf (i left 
out non-php-relevant entries):
---
LoadModule cgi_module 
/usr/lib64/apache2-prefork/mod_cgi.so
LoadModule php5_module                    /usr/lib64/apache2/mod_php5.so
LoadModule fcgid_module                   /usr/lib64/apache2/mod_fcgid.so
LoadModule suexec_module 
/usr/lib64/apache2-prefork/mod_suexec.so
---

Both CGI and FastCGI use
:/usr/bin/ # php-cgi5 -v
PHP 5.2.9 with Suhosin-Patch 0.9.7 (cgi-fcgi) (built: Mar 12 2009 16:17:38)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

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'.



a) Settings for using CGI

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


/srv/www/vhosts/domain.tld/conf/httpd.include
---
<VirtualHost <IP>:80>
....
        <Directory /srv/www/vhosts/domain.tld/httpdocs>
        <IfModule mod_perl.c>
        <Files ~ (\.pl$)>
                SetHandler perl-script
                PerlHandler ModPerl::Registry
                Options ExecCGI
                allow from all
                PerlSendHeader On
        </Files>
        </IfModule>
        <IfModule mod_python.c>
        <Files ~ (\.py$)>
                SetHandler python-program
                PythonHandler   mod_python.cgihandler
        </Files>
        </IfModule>
        <IfModule mod_fcgid.c>
                <Files ~ (\.fcgi)>
                        SetHandler fcgid-script
                        Options +FollowSymLinks +ExecCGI
                </Files>
        </IfModule>
        <Files ~ (\.php)>
                AddHandler php-script .php
                Options +ExecCGI
                allow from all
        </Files>
                Options -Includes -ExecCGI
        </Directory>
        Include /srv/www/vhosts/domain.tld/conf/vhost.conf
</VirtualHost>


b) Settings for using FastCGI which is mod_fcgid is selected form Plesk:

<VirtualHost <IP>:80>
...
        <Directory  /srv/www/vhosts/domain.tld/httpdocs>
        <IfModule mod_perl.c>
        <Files ~ (\.pl$)>
                SetHandler perl-script
                PerlHandler ModPerl::Registry
                Options ExecCGI
                allow from all
                PerlSendHeader On
        </Files>
        </IfModule>
        <IfModule mod_python.c>
        <Files ~ (\.py$)>
                SetHandler python-program
                PythonHandler   mod_python.cgihandler
        </Files>
        </IfModule>
        <IfModule mod_fcgid.c>
                <Files ~ (\.fcgi)>
                        SetHandler fcgid-script
                        Options +FollowSymLinks +ExecCGI
                </Files>
        </IfModule>
        <IfModule mod_fcgid.c>
        <Files ~ (\.php)>
                SetHandler fcgid-script
                FCGIWrapper /usr/bin/php-cgi5 .php
                Options +ExecCGI
                allow from all
        </Files>
        </IfModule>
                Options -Includes -ExecCGI
        </Directory>
        Include /srv/www/vhosts/domain.tld/conf/vhost.conf
</VirtualHost>

/etc/apache2/conf.d/mod_fcgid.conf
---
################################################################################
##
## Sample config for apache2_mod-fcgid
##
## All lines, that are commented out, reflect the default values.
##

<IfModule fcgid_module>
##
## An idle fastcgi application will be terminated after IdleTimeout seconds.
##
#IdleTimeout 300

##
## The scan interval for idle fastcgi applications in seconds.
##
#IdleScanInterval 120

##
## a fastcgi application will be terminated if handing a single request 
longer
## than busy timeout. Value in seconds.
##
#BusyTimeout 300

##
## The scan interval for busy timeout fastcgi applications. Value in 
seconds.
##
#BusyScanInterval 120

##
## The scan interval for exit pending fastcgi applications. fastcgi 
applications
## will be terminated within this scanning. Value in seconds.
##
#ErrorScanInterval 3

##
## The scan interval for zombie process. Value in seconds.
##
#ZombieScanInterval 3

##
##
## [HOWTO] PHP_AUTH_USER/_PW fuerr PHP-CGI
## 
http://forum.webhostlist.de/forum/webserver-software-linux-unix-etc/102327-howto-php_auth_user-_pw-fuer-php-cgi.html
##
PassHeader Authorization
PHP_Fix_Pathinfo_Enable 1
##
##
## A fastcgi application will be terminated if lifetime expired, even no 
error
## is detected. Value in seconds.
##
#ProcessLifeTime 3600

##
## The directory to put the UNIX domain socket. (UNIX only)
##
SocketPath /var/lib/apache2/fcgid/

##
## The share memory file path.
##
SharememPath /var/lib/apache2/fcgid/shm

##
## The spawn-speed control score up water limit. Score increases while a 
process
## is spawned or terminated, and decreases as time progresses; while the 
score is
## higher than SpawnScoreUpLimit, the spawning will be held for a while. The
## higher this number is, the higher speed of the spawning can be.
##
#SpawnScoreUpLimit n (10)

##
## The weight of spawning.  This weight will be plused to the spawn-control
## score on every spawn. The higher this number is, the lower speed of 
spawning
## can be.
##
#SpawnScore n (1)

##
## The weight of termination. This weight will be plused to the score while
## fastcgi process terminates. The higher this number is, the lower speed of
## spawning can be.
##
#TerminationScore n (2)

##
## The max count of total fastcgi process count.
##
#MaxProcessCount n (1000)

##
## The maximum number of fastcgi application instances allowed to run for 
any
## one fastcgi application.
##
#DefaultMaxClassProcessCount n (100)

##
## The default environment variables before a fastcgi application is 
spawned.
## You can set this configuration more than once.
##
#DefaultInitEnv  env_name env_value

##
## The connect timeout to a fastcgi application. Value in seconds.
##
## Default value: 2
##
IPCConnectTimeout 10

##
## The communication timeout to a fastcgi application. Please increase this
## value if your CGI have a slow initialization or slow respond. Value in
## seconds.
##
## Default value: 5
##
IPCCommTimeout 40

##
## CGI output cache buffer size. Value in kilobytes.
##
#OutputBufferSize 64

##
## Associate .fcgi files with mod_fcgid
##
#AddHandler fcgid-script .fcgi

##
## PHP via FastCGI
##
## uncomment the following line if you want to handle php via mod_fcgid
##
#<FilesMatch "\.php$">
#    AddHandler fcgid-script .php
#    FCGIWrapper /srv/www/cgi-bin/php5 .php
#    Options +ExecCGI
#</FilesMatch>
##
</IfModule>
# End of <IfModule fcgid_module>

##
################################################################################
---


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.


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.


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"]

and of course the same _ENV variables as there is only _ENV["PATH"] set 
anyway with mod_fcgid.



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 hope this clearifies the situation a lot more instead of causing even more 
confusion.

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).

TIA,
Marcus



Reply via email to