Slides: The Next Generation: mod_perl 2.0
* Why rewrite?
* What's new in Apache 2.0
* What's new in Perl 5.6.0 - 5.8.0
* What's new in mod_perl 2.0
* Installing mod_perl 2.0
* Configuring mod_perl 2.0
* Migrating from 1.0 to 2.0
* New Phases
* Protocol Handlers
* Filter Handlers
* TicketMaster rules!!!
* To make things simple here and in the new docs:
* mod_perl:
* * mod_perl 1.0 (not mod_perl 1.xx)
* * mod_perl 2.0 (not mod_perl 2.0.xx)
* Apache:
* * Apache 1.3
* * Apache 2.0
* Too patchy (6 years!), backward compatibility with:
* * Apache 1.3.0 - 1.3.27
* * Perl 5.003 - 5.8.0
* mod_perl 2.0 starts afresh with:
* * Apache 2.0 (incompatible with Apache 1.3)
* * Perl 5.6.0 (has semi-thread-safe Perl Interpreters)
* * Threaded mpms: 5.8.0 (really thread-safe)
* A new build system autogenerates the code used to
* * autogenerates the code that is used to ...
* * ...
* * which generates the final code ...
* * ... and it all works
* Automatically supports new Apache APIs
* The core:
All tests successful. Files=75, Tests=504, 65 wallclock secs ...
* Any Perl module needing mod_perl 1.0 or 2.0
* Any Apache module (both 1.3 and 2.0), PHP, Python, C...
* Already used by httpd-test to test Apache!!!
* Apache Portable Runtime
* Multi Processing Model modules (MPMs).
* * processes: prefork
* * threads: worker, leader, perchild...
* * os: mpmt_os2, netware, winnt, beos...
* Protocol Modules (HTTP, POP3, SMTP...)
* I/O Filtering
* Bucket Brigades
* Parsed Configuration Tree
* New Hook Scheme (Flexible, Order-able)
* Optional Functions
* Thread-safe Interpreter (5.8.0) via perl_clone()
* Subroutine attributes:
sub handler : FilterRequestHandler { ... }
* CORE::GLOBAL:: subs overriding CORE::
CORE::GLOBAL::
CORE::
* PerlIO layers => APR::PerlIO:
APR::PerlIO
open my $fh, "<:APR", $file, $r;
* I18n: Unicode, UTF...
* All the new Apache 2.0 and Perl 5.6.0+ features
* Plus its own new features
* Thread Interpreters Pool
* scalar @perl_interpreters != scalar @apache_threads
* * no need for front-end/back-end separation
* Two classes of interpreters: parent and clone
* parent: preload modules and perl_clone() clones
* clones: do the real work
* * mutable data is copied by the clone
* * read-only data such as the syntax tree is shared
* * clone pools are FIFO => memory re-use
* Manipulating Perl data is thread-safe (5.8.0)
push(), map(), chomp(), ...
* The rest, depends on the underlying implementation
localtime(), readdir(), srand(), ...
* Thread-safe but Process-scoped
chdir(), umask(), chroot(), ...
* See perlthrtut(3)
* mod_perl 2.0 Perl libs go to Apache2/
* Adjust @INC:
@INC
use Apache2 (); # @INC before: /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi # @INC after: /usr/lib/perl5/site_perl/5.8.0/i686-linux-thread-multi/Apache2
use Apache2 (); # use Apache::compat (); # 1.0 compat use lib qw(/home/httpd/perl); use ModPerl::Util (); #for CORE::GLOBAL::exit use Apache::RequestRec (); use Apache::RequestIO (); use Apache::RequestUtil (); use Apache::Server (); use Apache::ServerUtil (); use Apache::Connection (); use Apache::Log (); use APR::Table (); use ModPerl::Registry (); use Apache::Const -compile => ':common'; use APR::Const -compile => ':common'; 1;
PerlOptions
* Disable mod_perl for a given VirtualHost:
VirtualHost
<VirtualHost ...> PerlOptions -Enable </VirtualHost>
* Give the VirtualHost its own interpreter pool.
<VirtualHost ...> PerlOptions +Clone PerlInterpStart 2 PerlInterpMax 2 </VirtualHost>
* Run different versions of the same module:
<VirtualHost ...> ServerName dev1 PerlOptions +Parent PerlSwitches -Mblib=/home/dev1/lib/perl </VirtualHost> <VirtualHost ...> ServerName dev2 PerlOptions +Parent PerlSwitches -Mblib=/home/dev2/lib/perl </VirtualHost>
* disallow certain handlers/options
<VirtualHost ...> PerlOptions -Authen -Authz -Access -Sections </VirtualHost>
* Or maybe everything but the response handler:
<VirtualHost ...> PerlOptions None +Response </VirtualHost>
* Resolve Perl*Handlers at startup time:
Perl*Handlers
PerlOptions +Autoload PerlResponseHandler Apache::Magick
* Disable the global request_rec (Apache->request)
request_rec
Apache->request
<Location ...> SetHandler perl-script PerlOptions -GlobalRequest ... </Location>
* All the information can be found at:
http://perl.apache.org/docs/
* Further Questions?
* * Grab me at the corridor and demand answers
* * Ask at modperl@perl.apache.org
To install DocSet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DocSet
CPAN shell
perl -MCPAN -e shell install DocSet
For more information on module installation, please visit the detailed CPAN module installation guide.