perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Initial setup problems with mod_perl2 - unable to locate modules
Date Fri, 14 Feb 2014 16:29:01 GMT
André Warnier wrote:
> Hi.
> Da Rock wrote:
>> I know this may seem straight forward and a RTFM response may be in 
>> order, but I have been trying to crack this for some days now 
>> (following attempts on and off, too, mind) and nothing I can google 
>> seems to point to an accurate answer on what the problem is here.
>> I'm running FreeBSD 9.x with Apache22, and installed mod_perl2 to try 
>> to switch away from php based development based on current requirements.
>> I have tried using a, but I would like to just use 
>> PerlSwitches -I instead (which from what I read is possible); 
>> regardless the issue remains the same.
>> I get a 500 response in the browser, and the logs have these errors:
>> "failed to resolve handler `Mod_home::Mod': Can't locate 
>> Mod_home/ in @INC"
> it should normally also show you what it finds in @INC.  What does it say ?
>> and simply "failed to resolve handler" in the main server log.
>> My config looks like this:
>> <VirtualHost <IP>:<PORT>>
>>     ServerName <server>
>>     ServerAlias <server>
>>     ServerAdmin <hostmaster>
>>     ErrorLog "/var/log/apache/<VHOST>-error.log"
>>     CustomLog "/var/log/apache/<VHOST>-access.log" common
>>     PerlOptions +Parent
>>     PerlSwitches -I/usr/local/www/<VHOST>/lib
> Can you show us the contents of that directory ?
>>     PerlInitHandler Apache2::Reload
>>     PerlModule Mod_home::Mod
> I don't think that you need the above.
>>     <Location /<VHOST>>
>>         SetHandler modperl
>>         PerlResponseHandler Mod_home::Mod
> These 2 lines above should be enough.
>>         Order allow,deny
>>         Allow from all
>>     </Location>
>> </VirtualHost>
>> I also have PerlModule Apache2::Reload in the httpd.conf.
>> Just to reiterate - I have tried this both as vhosting and as single 
>> server setup, and I cannot seem to resolve the same issue every single 
>> time.
>> Can someone please give the magical incantation to make this thing 
>> work? :-) or at least point me in the right direction? I'm really 
>> starting to lose patience with this thing, and I now have a deadline 
>> to sort this out which is fast approaching.
> Yes, but that's not the fault of anyone who is trying to help you here.
> So be patient.
> I am doing things similar to what you are intenting to do, on many 
> servers with VirtualHosts, and it works flawlessly.  So it /is/ a 
> configuration matter, not something wrong with Apache/mod_perl in the 
> first place.
> The thing is, we don't see your system, so we depend on the accurate and 
> complete information that you are providing us with.
> When you (re-)start your Apache server, it prints a statup line in the 
> logs (error log).
> Can you show it here ?
> example :
> [Sun Feb 09 06:25:45 2014] [notice] Apache/2.2.16 (Debian) mod_jk/1.2.30 
> mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
> and then give us the *full* message that appears in the log when it 
> doesn't find your module.

Example of a configuration which works (Linux Debian, Apache 2.2, mod_perl 2.0) :

1) Apache config, "main" server :
LoadModule perl_module /usr/lib/apache2/modules/
PerlSetEnv TMPDIR "/tmp"
PerlOptions +GlobalRequest
PerlRequire "/etc/apache2/"
SetEnv PERL5LIB "/somepath/lib" # one way of setting the modules lookup path

and in :

# Apache2 / mod_perl 2 startup script
   use Bundle::Apache2 ();
   use lib "/somepath/lib"; # another way of setting the modules lookup path
# preload often-used modules, YMMV
   use ModPerl::Util ();
   use Apache2::RequestRec ();
   use Apache2::RequestIO ();
   use Apache2::RequestUtil ();
   use Apache2::Filter ();
   use Apache2::ServerUtil ();
   use Apache2::Connection ();
   use Apache2::Log ();
   use Apache2::Const -compile => qw(:common :log REDIRECT);
   use APR::Const -compile => ':common';
   use APR::Table ();
   use ModPerl::Registry ();
   use CGI ();

2) in VHost config :

	PerlSetVar Var1 "Value1"
	PerlSetVar Var2 "Value2"

	<Directory /var/www/<vhost>/docs>
		AuthType AUTH::StarLogCookie
		AuthName XXXtop
		PerlAuthenhandler AUTH::StarLogCookie->authenticate
		PerlAuthzHandler AUTH::StarLogCookie->authorize
		require valid-user

That was just to show off that you can do all kinds of things with mod_perl.
But here is something closer to your wishes :

         <Location /getobj>
             SetHandler modperl
	    PerlSetVar Var1 "Valuex" # overrides the general one above
	    PerlSetVar Var3 "Value3"
             PerlResponseHandler My::Module     # or My::Module->handler, it depends

and in /something/lib/, there is :

- My

and has a

sub handler() {


So you do not need to specifically "load" My::Module in advance.
The PerlResponseHandler should be enough.

View raw message