- mod_perl-2.0.3.tar.gz
- Assuming apache2 is installed
Operating system
- Linux
- I am using Fedora core 5 but these steps should work fine for most of the linux systems
Installing mod_perl
tar -xvzf mod_perl-2.0.3.tar.gz
cd mod_perl-2.0.3
run
# which apxs
if its not found then do a
#yum nstall httpd-devel ;# works on FC
for others get a compatible version of your httpd-devel and install it
as apxs gives the information required to build the mod_perl.so module.
do a
#which apxs
again to check where its installed
Assuming that its installed in /usr/bin/apxs
Run
#perl MakeFile.PL MP_APXS=/usr/bin/apxs
#make
#make test
#make install
this would install all the modules required to run mod_perl in the PERL5LIB path
Copy the mod_perl.so to your <
Edit your httpd.conf and add
LoadModule perl_module modules/mod_perl.so
And now restart your server.
Testing the mod_perl module.
create a /var/www/html/perl/rock.pl
print "Content-type: text/html\n\n";
print "mod perl rocks";
print "
test
";Edit your httpd.conf and add the following
Alias /perl/
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
Try to access from your browser
http://localhost/perl/rocks.pl
Using a module to handle a request
create a file Hello.pm and make sure the path exists in @INC
to check the @INC paths
perl -e 'print join("\n",@INC)'
type the following in
package Hello;
use Apache2::RequestRec();
use Apache2::RequestIO();
use Apache2::Const -compile=>qw(OK);
sub handler{
my $r=shift;
$r->content_type('text/html');
print 'welcome';
return Apache2::Const::OK;
}
1;
edit your httpd.conf and add
PerlModule Hello
SetHandler perl-script
PerlResponseHandler Hello
PerlSendHeader On
Use a browser now and try the URL
http://localhost/HI
Useful links
http://www.perl.com/pub/a/2002/02/26/whatismodperl.html
http://www.revsys.com/writings/modperl.html
No comments:
Post a Comment