You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Will Trillich <wi...@serensoft.com> on 2003/04/27 06:47:52 UTC

startup.pl config: invalid command 'SetHandler'?

On Wed, Apr 23, 2003 at 01:28:25PM -0400, Geoffrey Young wrote:
> Will Trillich wrote:
> >I swear this worked at least once yesterday -- but now i can't
> >seem to use SetHandler directives in %VirtualHost <Perl> code...

okay, we can ixnay the <Perl> paradigm from my original post --
this is still just as broken using startup.pl...

> >	#httpd.conf for apache 1.3.26:
> >	#<snip>
> >	LoadModule mime_module /usr/lib/apache/1.3/mod_mime.so
> 
> >[Tue Apr 22 03:28:42 2003] [error] (22)Invalid argument: <Perl>: Invalid 
> >command 'SetHandler', perhaps mis-spelled or defined by a module not 
> >included in the server configuration
> 
> to me, this means that mod_mime is not loading properly.  maybe your 
> LoadModule statement is incorrect, or maybe mod_perl is parsing <Perl> 
> sections before mod_mime is added to the module list.
> 
> so, the first thing I would try is a SetHandler call outside of a <Perl> 
> section - that way you know if mod_mime is installed properly.  next I 
> would try rearranging modules with ClearModuleList and AddModule, placing 
> mod_mime both before and after mod_perl in the module list to see what 
> happens.  the lower in httpd.conf, the higher the priority.

reasonable conclusion -- yet "SetHandler" is indeed used within
the httpd.conf to set up /status and /info thus:

	<IfModule mod_status.c>
		<Location /status>
			SetHandler server-status
			<IfModule mod_access.c>
				Order deny,allow
				Deny from all
				Allow from 10.1.1 192.168.
			</IfModule>
		</Location>
	</IfModule>

	<IfModule mod_info.c>
		<Location /info>
			SetHandler server-info
			<IfModule mod_access.c>
				Order deny,allow
				Deny from all
				Allow from 10.1.1 192.168.
			</IfModule>
		</Location>
	</IfModule>

those both work like a charm from the browser, so SetHandler is
confirmed as working properly (indicating that mod_mime is
loaded and operational). but using this code in startup.pl still
goes poof:

	%VirtualHost = (
	  '10.1.1.1' => {
	    'DocumentRoot' => '/var/www/',
	    'DirectoryIndex' => [ 'index.md', 'index.html' ],
	    'ServerAlias' => '*myserver.com',
	    'ServerName' => 'www.myserver.com',
	    'SetHandler' => 'perl-script', # <<<< BOOM!
	    'PerlTransHandler' => 'My::Trans::handler'
	  }
	);

as indicated in the logs:
[Sat Apr 26 23:20:07 2003] [notice] caught SIGTERM, shutting down
[Sat Apr 26 23:20:13 2003] [error] (22)Invalid argument: <Perl>: Invalid command 'SetHandler', perhaps mis-spelled or defined by a module not included in the server configuration
[Sat Apr 26 23:20:13 2003] [warn] NameVirtualHost 10.1.1.1:80 has no VirtualHosts
[Sat Apr 26 23:20:13 2003] [notice] Apache/1.3.26 (Unix) Debian GNU/Linux mod_perl/1.26 configured -- resuming normal operations
[Sat Apr 26 23:20:13 2003] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache/suexec)
[Sat Apr 26 23:20:13 2003] [notice] Accept mutex: sysvsem (Default: sysvsem)

note that i'm no longer using <Perl> sections in httpd.conf, but
the error message apparently uses that concept by default.



[Sat Apr 26 23:20:13 2003] [warn] NameVirtualHost 10.1.1.1:80 has no VirtualHosts

what the heck? no virtual hosts?



Also -- i noticed that the trans handler DOES seem to be
working, as it logs connections-per-session (via cookie) and the
log and the database both indicate that it's operating properly.

so why is the server spewing source code, albeit from different
hosts despite the fact that 'no virtual hosts' are configured?
there must be something i did that borks the innards somehow...



> personally, I've never seen anybody use mod_mime as a DSO module before - 
> it's so integral to the way Apache operates that it really doesn't make 
> sense to not compile it statically - there are few (if any) circumstances 
> where you _wouldn't_ want mod_mime.  but the choice is yours :)

i'm using the out-of-the-box apache-perl package from debian
stable (woody) which has mod_perl compiled in, and everything
else is optional/modules. when i get things singing on key, i
may step back and rearrange the choir a bit -- until then, tho,
modules are gonna stay as is. :)

-- 
will trillich
mayhugh services

Re: startup.pl config: invalid command 'SetHandler'?

Posted by Will Trillich <wi...@serensoft.com>.
apache 1.3.26 still --

On Sun, Apr 27, 2003 at 04:06:54AM -0500, Will Trillich wrote:
> okay, i even tried @PerlConfig -- dump and error output is as
> follows, which has me wanting to call the funny farm:
> 
> package Apache::ReadConfig;
> #hashes:
> 
> %VirtualHost = (
>   '10.1.1.1' => []
> );
> 
> #arrays:
> 
> @PerlConfig = (
>   '<VirtualHost 10.1.1.1>',
>   '     ServerName   www.midwestRepo.com',
>   '     ServerAlias  *midwestRepo.com',
>   '#    ServerAdmin  webmaster@midwestRepo.com',
>   '     DocumentRoot /var/www/midwestRepo.com',
>   '     PerlTransHandler Repo::Trans::handler',
>   '#    PerlHandler  see $r->set_handler in Repo::Trans::handler',
>   '     DirectoryIndex index.md index.html',
>   '     <Location />',
>   '             AllowOverride all',
>   '             Options       -Indexes -Includes +FollowSymLinks +ExecCGI',
>   '             SetHandler    perl-script',
>   '             Order allow,deny',
>   '             Allow from all',
>   '     </Location>',
>   '</VirtualHost>'
> );
> 
> #scalars:
> 
> $DocumentRoot = '/var/www';
> 
> $ServerRoot = '/etc/apache-perl';
> 
> $NameVirtualHost = '10.1.1.1';
> 
> 1;
> __END__
> mod_perl: Missing </VirtualHost> directive at end-of-file
> mod_perl: ServerAlias only used in <VirtualHost>
> mod_perl: Missing </Location> directive at end-of-file
> mod_perl: </Location> without matching <Location> section
> mod_perl: </VirtualHost> not allowed here
> [Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: DocumentRoot not allowed here
> [Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: ServerRoot not allowed here
> [Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: NameVirtualHost not allowed here
> Syntax error on line 417 of /etc/apache-perl/httpd.perl.conf:
> <VirtualHost not allowed here
> 
> 
> the /VirtualHost directive is ostensibly NOT missing. the
> /Location directive is ostensible NOT missing. the ServerAlias IS
> within a VirtualHost block.
> 
> i think i need stronger medication.

aha, says me, maybe a block (<IfModule> or <Location> or
<VirtualHost>) needs to be in a self-contained $PerlConfig[*]
item instead of spread across several virtual "lines" in the
array (seems silly not to facilitate that, but here goes...)

now i've got the whole "concatenate strings" rigamarole going,
and i push it en toto as one element of the @PerlConfig array:

@PerlConfig = (
  '<VirtualHost 10.1.1.1>
        ServerName   www.midwestRepo.com
        ServerAlias  *midwestRepo.com
#       ServerAdmin  webmaster@midwestRepo.com
        DocumentRoot /var/www/midwestRepo.com
        PerlTransHandler Repo::Trans::handler
#       PerlHandler  see $r->set_handler in Repo::Trans::handler
<IfModule mod_userdir.c>
        UserDir disabled
</IfModule>
<IfModule mod_dir.c>
        DirectoryIndex index.md index.html
</IfModule>
        <Location />
                AllowOverride all
                Options       -Indexes -Includes +FollowSymLinks +ExecCGI
                SetHandler    perl-script
<IfModule mod_access.c>
                        Order allow,deny
                        Allow from all
</IfModule>
        </Location>
</VirtualHost>
'
);

and now there's no complaint about SetHandler, but not only does
10.1.1.1:80 have no virtualhosts for some godawful reason,
neither does 10.1.1.1:0?

[Sun Apr 27 04:12:17 2003] [notice] caught SIGTERM, shutting down
[Sun Apr 27 04:12:24 2003] [warn] NameVirtualHost 10.1.1.1:0 has no VirtualHosts
[Sun Apr 27 04:12:24 2003] [warn] NameVirtualHost 10.1.1.1:80 has no VirtualHosts
[Sun Apr 27 04:12:24 2003] [notice] Apache/1.3.26 (Unix) Debian GNU/Linux mod_perl/1.26 configured -- resuming normal operations
[Sun Apr 27 04:12:24 2003] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache/suexec)
[Sun Apr 27 04:12:24 2003] [notice] Accept mutex: sysvsem (Default: sysvsem)

and this time i believe it, because it doesn't adhere to the
documentroot for the virtual host as it had been before (even
though it complained before).

i still need stronger medication. or a big clue-whap.

-- 
will trillich
mayhugh services


Re: startup.pl config: invalid command 'SetHandler'?

Posted by Will Trillich <wi...@serensoft.com>.
On Sun, Apr 27, 2003 at 03:15:12AM -0500, Will Trillich wrote:
> %VirtualHost = (
>   '10.1.1.1' => [
>     {
>       'DocumentRoot' => '/var/www/dontUthink.com/house',
>       'DirectoryIndex' => [
>         'index.md',
>         'index.html'
>       ],
>       'ServerAdmin' => 'webmaster@dontUthink.com',
>       'Directory' => {
>         '/var/www/dontUthink.com/house' => {
>           'FilesMatch' => {
>             '(\\.mc|^(auto|d)handler)$' => {
>               'PerlHandler' => 'Apache::Constants::NOT_FOUND',
>               'SetHandler' => 'perl-script'
>             },
>             '(\\.html|\\.txt|\\.md|^[^.]+)$' => {
>               'PerlHandler' => 'Mason::dontUthink::handler',
>               'SetHandler' => 'perl-script'
>             }
>           },
>           'AllowOverride' => 'all',
>           'Options' => '-Indexes -Includes +FollowSymLinks +ExecCGI'
>         }
>       },
>       'ServerName' => 'house.dontUthink.com'
>     },
>     {
>       'Location' => {
>         '/' => {
>           'AllowOverride' => 'all',
>           'Options' => '-Indexes -Includes +FollowSymLinks +ExecCGI',
>           'SetHandler' => 'perl-script'
>         }
>       },
>       'DocumentRoot' => '/var/www/midwestRepo.com',
>       'DirectoryIndex' => [
>         'index.md',
>         'index.html'
>       ],
>       'ServerAlias' => '*midwestRepo.com',
>       'ServerName' => 'www.midwestRepo.com',
>       'PerlTransHandler' => 'Repo::Trans::handler'
>     }
>   ]
> );
> 
> and i still get the errors: note there are three SetHandler
> directives, and i get three lines of matching complaints in
> error.log (plus a 'no virtual hosts' snag, and then it dishes
> out source code).

trying to track this down, i removed one virtual host (the house
one) and added this to my midwestrepo.com startup.pl code:

	<snip>
	Location     => {
		'/' => {
			AllowOverride => 'all',
			Options       => q/-Indexes -Includes +FollowSymLinks +ExecCGI/,
			SetHandler    => 'perl-script',
Apache->module('mod_access.c')
? (
			Order => 'allow,deny',
			Allow => 'from all',
)
: (
),
		},
	},
	<snip>

so i'm testing for the module "mod_access.c" before using its
directives -- and look:

[Sun Apr 27 03:32:23 2003] [error] (22)Invalid argument: <Perl>: Invalid command 'Order', perhaps mis-spelled or defined by a module not included in the server configuration
[Sun Apr 27 03:32:23 2003] [error] (22)Invalid argument: <Perl>: Invalid command 'Allow', perhaps mis-spelled or defined by a module not included in the server configuration
[Sun Apr 27 03:32:23 2003] [error] (22)Invalid argument: <Perl>: Invalid command 'SetHandler', perhaps mis-spelled or defined by a module not included in the server configuration

i still can't figure it out, but there's gotta be a pattern here.
(yes, in the httpd.conf above the PerlRequire startup.pl, there
are several Order and Allow directives that seem to work.)



this is the debian/stable package "apache-perl"

	Server version: Apache/1.3.26 (Unix) Debian GNU/Linux
	Server built:   Nov  5 2002 06:43:12



###

another note -- when tinkering with <Perl></Perl> sections in
httpd.conf, i did a "print __PACKAGE__" and it showed
"ApacheReadConfig" all as one solid word, as opposed to
"Apache::ReadConfig" with the double-colons as mentioned in the
eagle book and encouraged by Apache::PerlSections->dump(). is
this significant or pertinent somehow?

(didn't appear to affect anything whether using :: or not)

###



okay, i even tried @PerlConfig -- dump and error output is as
follows, which has me wanting to call the funny farm:

package Apache::ReadConfig;
#hashes:

%VirtualHost = (
  '10.1.1.1' => []
);

#arrays:

@PerlConfig = (
  '<VirtualHost 10.1.1.1>',
  '     ServerName   www.midwestRepo.com',
  '     ServerAlias  *midwestRepo.com',
  '#    ServerAdmin  webmaster@midwestRepo.com',
  '     DocumentRoot /var/www/midwestRepo.com',
  '     PerlTransHandler Repo::Trans::handler',
  '#    PerlHandler  see $r->set_handler in Repo::Trans::handler',
  '     DirectoryIndex index.md index.html',
  '     <Location />',
  '             AllowOverride all',
  '             Options       -Indexes -Includes +FollowSymLinks +ExecCGI',
  '             SetHandler    perl-script',
  '             Order allow,deny',
  '             Allow from all',
  '     </Location>',
  '</VirtualHost>'
);

#scalars:

$DocumentRoot = '/var/www';

$ServerRoot = '/etc/apache-perl';

$NameVirtualHost = '10.1.1.1';

1;
__END__
mod_perl: Missing </VirtualHost> directive at end-of-file
mod_perl: ServerAlias only used in <VirtualHost>
mod_perl: Missing </Location> directive at end-of-file
mod_perl: </Location> without matching <Location> section
mod_perl: </VirtualHost> not allowed here
[Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: DocumentRoot not allowed here
[Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: ServerRoot not allowed here
[Sun Apr 27 03:58:42 2003] [error] (2)No such file or directory: <Perl>: NameVirtualHost not allowed here
Syntax error on line 417 of /etc/apache-perl/httpd.perl.conf:
<VirtualHost not allowed here


the /VirtualHost directive is ostensibly NOT missing. the
/Location directive is ostensible NOT missing. the ServerAlias IS
within a VirtualHost block.

i think i need stronger medication.

-- 
will trillich
mayhugh services


Re: startup.pl config: invalid command 'SetHandler'?

Posted by Perrin Harkins <pe...@elem.com>.
Will Trillich wrote:
> and i still get the errors: note there are three SetHandler
> directives, and i get three lines of matching complaints in
> error.log (plus a 'no virtual hosts' snag, and then it dishes
> out source code).

Have you tried turning on MOD_PERL_TRACE s?  Does it work when you do 
this in the standard way, as plain text in httpd.conf?

I'm afraid I'm really just shooting in the dark here, since I've never 
used PerlSections.

- Perrin


Re: startup.pl config: invalid command 'SetHandler'?

Posted by Will Trillich <wi...@serensoft.com>.
On Sun, Apr 27, 2003 at 01:48:19AM -0400, Perrin Harkins wrote:
> Will Trillich wrote:
> >	%VirtualHost = (
> >	  '10.1.1.1' => {
> >	    'DocumentRoot' => '/var/www/',
> >	    'DirectoryIndex' => [ 'index.md', 'index.html' ],
> >	    'ServerAlias' => '*myserver.com',
> >	    'ServerName' => 'www.myserver.com',
> >	    'SetHandler' => 'perl-script', # <<<< BOOM!
> >	    'PerlTransHandler' => 'My::Trans::handler'
> >	  }
> >	);
> 
> You can't set a handler for the whole VirtualHost.  It has to be inside 
> a Location or Files block.

right.  i was trying to save a bit on bandwidth by trimming my
email... here's the actual setup (as you can surmise, i use
HTML::Mason):

%VirtualHost = (
  '10.1.1.1' => [
    {
      'DocumentRoot' => '/var/www/dontUthink.com/house',
      'DirectoryIndex' => [
        'index.md',
        'index.html'
      ],
      'ServerAdmin' => 'webmaster@dontUthink.com',
      'Directory' => {
        '/var/www/dontUthink.com/house' => {
          'FilesMatch' => {
            '(\\.mc|^(auto|d)handler)$' => {
              'PerlHandler' => 'Apache::Constants::NOT_FOUND',
              'SetHandler' => 'perl-script'
            },
            '(\\.html|\\.txt|\\.md|^[^.]+)$' => {
              'PerlHandler' => 'Mason::dontUthink::handler',
              'SetHandler' => 'perl-script'
            }
          },
          'AllowOverride' => 'all',
          'Options' => '-Indexes -Includes +FollowSymLinks +ExecCGI'
        }
      },
      'ServerName' => 'house.dontUthink.com'
    },
    {
      'Location' => {
        '/' => {
          'AllowOverride' => 'all',
          'Options' => '-Indexes -Includes +FollowSymLinks +ExecCGI',
          'SetHandler' => 'perl-script'
        }
      },
      'DocumentRoot' => '/var/www/midwestRepo.com',
      'DirectoryIndex' => [
        'index.md',
        'index.html'
      ],
      'ServerAlias' => '*midwestRepo.com',
      'ServerName' => 'www.midwestRepo.com',
      'PerlTransHandler' => 'Repo::Trans::handler'
    }
  ]
);

and i still get the errors: note there are three SetHandler
directives, and i get three lines of matching complaints in
error.log (plus a 'no virtual hosts' snag, and then it dishes
out source code).

aaugh!

(by the way -- is the FilesMatch hashref syntax appropriate for
what i'm after? it's a pretty straight translate from httpd.conf
but i'm not sure about using a regex as a hash key...)

-- 
will trillich
mayhugh services
812 423 6314 voice
812 423 6303 fax


Re: startup.pl config: invalid command 'SetHandler'?

Posted by Perrin Harkins <pe...@elem.com>.
Will Trillich wrote:
> 	%VirtualHost = (
> 	  '10.1.1.1' => {
> 	    'DocumentRoot' => '/var/www/',
> 	    'DirectoryIndex' => [ 'index.md', 'index.html' ],
> 	    'ServerAlias' => '*myserver.com',
> 	    'ServerName' => 'www.myserver.com',
> 	    'SetHandler' => 'perl-script', # <<<< BOOM!
> 	    'PerlTransHandler' => 'My::Trans::handler'
> 	  }
> 	);

You can't set a handler for the whole VirtualHost.  It has to be inside 
a Location or Files block.

- Perrin