LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-07-2010, 11:20 AM   #1
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Rep: Reputation: 15
Apache: Global $r object is not available. Set: PerlOptions +GlobalRequest


Hi,
I setup a Suse 11.2 server over a year ago and suddenly, after an online software update, my Apache server is broken. It just writes a few lines to the error log and produces no output. Here is the error message:
Global $r object is not available. Set:
PerlOptions +GlobalRequest
in httpd.conf at /usr/lib/perl5/5.10.0/CGI/Carp.pm line 553.

I looked at the Carp.pm line 553:
$r = Apache2::RequestUtil->request;
The online documentation from
http://search.cpan.org/~gozer/mod_pe...equestUtil.pod
says:
# get the global request object (requires PerlOptions +GlobalRequest)
$r = Apache2::RequestUtil->request;

I have +GlobalRequest set in my mod_perl.conf file for location /perl/ which is aliased to /rr/www/cgi-bin/, the physical directory for my Perl scripts:
ScriptAlias /perl/ "/rr/www/cgi-bin/"
<Location /perl/>
# mod_perl mode
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
PerlOptions +GlobalRequest
Options +ExecCGI
</Location>

In the mod_perl-startup.pl script which is PerlRequired in the mod_perl.conf file, it uses the RequestUtil module:
use Apache2::RequestUtil ();

I thought to update apache and mod_perl, but they are both the latest versions in yast. I even rebooted.

Do I have PerlOptions +GlobalRequest in the wrong place? I have not done any system work since setup the server over a year ago except for running yast -> online_update.

Puzzled,

BrianP


vulcan:/etc/apache2/conf.d # uname -a
Linux vulcan 2.6.31.14-0.1-desktop #1 SMP PREEMPT 2010-09-17 11:32:00 +0200 x86_64 x86_64 x86_64 GNU/Linux

vulcan:/etc/apache2/conf.d # rpm -q apache2-mod_perl
apache2-mod_perl-2.0.4-41.5.x86_64
vulcan:/etc/apache2/conf.d # rpm -q apache2
apache2-2.2.13-2.4.1.x86_64

Details of conf files:
vulcan:/etc/apache2/conf.d # cat mod_perl.conf
<Directory "/rr/www/perl-lib">
AllowOverride None
Options None
Order allow,deny
Deny from all
</Directory>
<IfModule mod_perl.c>
PerlRequire "/etc/apache2/mod_perl-startup.pl"
ScriptAlias /perl/ "/rr/www/cgi-bin/"
<Location /perl/>
# mod_perl mode
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
PerlOptions +GlobalRequest
Options +ExecCGI
</Location>
ScriptAlias /cgi-perl/ "/rr/www/cgi-bin/"
<Location /cgi-perl>
# perl cgi mode
SetHandler perl-script
PerlResponseHandler ModPerl::PerlRun
PerlOptions +ParseHeaders
PerlOptions +GlobalRequest
Options +ExecCGI
</Location>
# The /cgi-bin/ ScriptAlias is already set up in httpd.conf
</IfModule>
# vim: ft=apache



From /usr/lib/perl5/5.10.0/CGI/Carp.pm
if ($mod_perl) {
my $r;
if ($ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION} == 2) {
$mod_perl = 2;
require Apache2::RequestRec;
require Apache2::RequestIO;
require Apache2::RequestUtil;
require APR::Pool;
require ModPerl::Util;
require Apache2::Response;
$r = Apache2::RequestUtil->request; << LINE 553 from error log.
}


vulcan:/etc/apache2/conf.d # cat /etc/apache2/mod_perl-startup.pl
# Taken from http://perl.apache.org/docs/2.0/user...l#Startup_File
if ( ! $ENV{MOD_PERL}) { die "GATEWAY_INTERFACE not Perl!"; }
use lib qw(/srv/www/perl-lib);
# enable if the mod_perl 1.0 compatibility is needed
# use Apache2::compat ();
# preload all mp2 modules
# use ModPerl::MethodLookup;
# ModPerl::MethodLookup:reload_all_modules();
use ModPerl::Util (); #for CORE::GLOBAL::exit
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::ServerRec ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use APR::Table ();
use ModPerl::Registry ();
use Apache2::Const -compile => ':common';
use APR::Const -compile => ':common';
1;
 
Old 10-07-2010, 03:56 PM   #2
brianpbarnes
Member
 
Registered: Dec 2005
Posts: 143

Original Poster
Rep: Reputation: 15
SOLUTION!
I don't know what changed in Apache or Mod_Perl, but here is an ugly hack to sidestep it:
Insert:
PerlOptions +GlobalRequest
as the first non-comment line in httpd.conf. All other perl directives are contained either in mod_perl-startup.pl or mod_perl.conf.

That fixed the first problem, but caused this one and zero output:
-e: failed to resolve handler Apache2::Reload

Execute cpan as root and install Apache2::Reload

Restart apache: /etc/init.d/apache2 restart

It's alive!! I wish they would do some testing before pushing code

BrianP
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to set global alias? exitsfunnel Linux - General 9 07-29-2014 09:12 AM
how do i set global alias in gentoo? lleb Linux - General 3 12-13-2007 01:38 PM
set a Global shortcut for my Application? mtux Programming 2 08-23-2007 02:47 PM
mod_perl error Invalid command 'PerlOptions' agentc0re Slackware 6 05-24-2007 01:22 PM
Where is global TERM variable set? tonyfreeman Red Hat 1 02-20-2007 02:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration