[mod_perl] Can't locate object method “X” via package “Apache2::RequestRec”
Bonjour à tous,
j'ai commencé a utiliser mod_perl sur mon serveur et je rencontre un petit souci.
J'ai dabord essayé sur un sous dossier, genre
mondomaine.fr/perl/ et la ca marche
Et si j'essaye la meme chose directement sur monddomaine.fr ca marche plus, et ca me met l'erreur :
Can't locate object method "content_type" via package "Apache2::RequestRec"
Si je ratjoute un use Apache2::RequestRec, ca change l'erreur de content_type a print, toujours dans le meme package.
Voici les codes utilisés,
celui qui marche pas
Code:
1 2 3 4 5 6 7 8 9 10
| package aw::main;
use Apache2::Const qw(:common);
sub handler {
my $r = shift;
$r->content_type("text/plain");
$r->print("mod_perl rules!\n");
return OK;
}
1; |
Celui qui marche:
Code:
1 2 3 4 5 6 7 8 9 10
| package test2::Rules2;
use Apache2::Const qw(:common);
sub handler {
my $r = shift;
$r->content_type("text/plain");
$r->print("mod_perl rules!\n");
return OK;
}
1; |
Et les deux virtual host pour le domaine et le sous domaine
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ***.fr.cr
DocumentRoot /var/www/aw
<Directory /var/www/aw/>
AllowOverride None
Order allow,deny
allow from all
</Directory>
PerlModule test2::Rules2
alias /perl2/ /usr/lib/perl5/test2/
<Location /perl2/>
Order allow,deny
allow from all
SetHandler perl-script
PerlHandler test2::Rules2
</Location>
ErrorLog ${APACHE_LOG_DIR}/aw.error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/aw.access.log combined
</VirtualHost> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ***.fr.cr
DocumentRoot /var/www/aw
<Directory /var/www/aw/>
AllowOverride None
Order allow,deny
allow from all
</Directory>
PerlModule aw::main
alias / /usr/lib/perl5/aw/
<Location />
Order allow,deny
allow from all
SetHandler perl-script
PerlHandler aw::main
</Location>
ErrorLog ${APACHE_LOG_DIR}/aw.error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/aw.access.log combined
</VirtualHost> |