Hi Jeff,
after another evening, this is what i came up with:
Goals:
1. I do not want to mess around with /etc/apache2/conf.d/mod_fcgid.conf
2. I do not want to be forced to always use mod_fcgid on virtual hosts that are
configured for mod_cgi (from Plesk)
I achieve this by doing all necessary changes in
/srv/www/vhosts/<domain.tld>/conf/vhost.conf (in case of a subdomain ist could
also be /srv/www/vhosts/domain.tld/subdomains/<subdomain>/conf/vhost.conf) and
amending the respective httpd.include file (in
/srv/www/vhosts/<domain.tld>/conf as well).
The downside is, that this httpd.include file gets generated by Plesk whenever
you change anything for that virtual host or a subdomain for that virtual host.
There is an event manager in Plesk where you can specify to run a specific
script after an event has taken place like 'hosting domain create/update' to
reverse any changes to httpd.include but it would require more work and
knowledge to write such a script, i.e. cutting the respective <IfModule
mod_fcgid.c> container (see below) and adding necessary code either in
httpd.include or a vhost.conf file. Certainly it is doable, though.
Fine.
[btw, maybe it was my fault but using your replacement code 1:1 causes every
file (tested with php or jpeg) to be offered for download by the browser
(tested on 2 different computers with FF 3.5.3, IE 6 and IE 8)]
To get mod_fcgid running with this watermark script and not to interfere with
virtual hosts configured to use mod_cgi, i did amend/extend a couple of things,
plus, i did add FCGIWrapper statement back in which might be useless but i
wanted to know whether that directive is part of the problem. Actually it is
not. The problem starts when using 'SetHandler fcgid-sript' instead of an
Alias/Action combination.
/etc/apache2/conf.d/mod_fcgid.conf is back to 'out-of-the-box' configuration. I
only added
PassHeader Authorization
PHP_Fix_Pathinfo_Enable 1
like before.
My httpd.include is:
<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>
so you could skip/delete the second <IfModule mod_fcgid.c> container from
httpd.include.
The included vhost.conf file then contains:
---
Alias /phpfcgidpath/ "/usr/bin/"
Action php-fcgid /phpfcgidpath/php-cgi5
<Location /phpfcgidpath/>
SetHandler fcgid-script
Options +ExecCGI
</Location>
<Files ~ (\.php)>
SetHandler php-fcgid
FCGIWrapper /usr/bin/php-cgi5 .php
Options +ExecCGI
allow from all
</Files>
---
The first two statements are basically similiar to the
/etc/apache2/conf.d/php_cgi.conf (and needed as i did replace /phppath/ with
/phpfcgidpath/ for which there is no ScriptAlias and Action statement in any
other *.conf file):
---
scriptAlias /phppath/ "/usr/bin/"
Action php-script /phppath/php-cgi5
---
As i wanted to have a testconfig which does not interfere with mod_cgi, i
changed from /phppath/ to /phpfcgidpath/ and did use Alias instead of
ScriptAlias because you used it in your replacement bit. In the end it does not
really matter.
This causes only virtual hosts which have this additional statement in its
vhost.conf to use mod_fcgid and the watermark image works with this
configuration.
As soon as you change the SetHandler statement in the vhost.conf from:
<Files ~ (\.php)>
SetHandler php-fcgid
FCGIWrapper /usr/bin/php-cgi5 .php
Options +ExecCGI
allow from all
</Files>
to
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /usr/bin/php-cgi5 .php
Options +ExecCGI
allow from all
</Files>
(which is the default from Plesk in httpd.include when switching to
FastCGI-Application), PHP tries to parse the jpg file again. This is expected
as changing the SetHandler directive as shown, the Alias and Action directive
are not used anymore as we do not use the Handler php-fcgid anymore and we are
back to square one.
Using this 'workaround' does have one other side-effect:
As we are using a Alias (or ScriptAlias) directive, now, when we call an URL
from a .htaccess protected directory -AuthType Basic in connection with
PassHeader Authrization-, the _SERVER["REMOTE_USER"] variable is empty and
_ENV["REDIRECT_REMOTE_USER"] is used instead. This is not really a problem, but
when you try to use PHP Auth, you have to adopt your scripts not only to test
for REMOTE_USER but also for REDIRECT_REMOTE_USER like
<?php
if (!isset($_SERVER["REMOTE_USER"]) &&
!isset($_SERVER["REDIRECT_REMOTE_USER"])) {
echo "Not authenticated";
} else {
<do something else>
}
?>
As i am curious, i would like to know what the difference in the mod_fcgid
source code is to cause such a different behaviour. Obviously you can get it to
work by the use of the Alias / Action combination with the SetHandler directive
but when using it as shown in the docs (and implemented by Plesk and a couple
of other GUI's i would guess) then this watermark script (and variations of
them) fail(s).
HTH,
Marcus