home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Mason-with-mod_perl2.pod < prev    next >
Encoding:
Text File  |  2004-02-03  |  22.5 KB  |  698 lines

  1.  
  2. =head1 NAME
  3.  
  4. HTML::Mason::ApacheHandler2 - experimental (alpha) Mason/mod_perl2 interface
  5.  
  6. =head1 SYNOPSIS
  7.  
  8.     use HTML::Mason::ApacheHandler2;
  9.  
  10.     my $ah = HTML::Mason::ApacheHandler2->new (..name/value params..);
  11.     ...
  12.     sub handler {
  13.        my $r = shift;
  14.        $ah->handle_request($r);
  15.     }
  16.  
  17. =head1 DESCRIPTION
  18.  
  19. B<HTML::Mason::ApacheHandler2 is highly experimental ( alpha ) and
  20. should only be used in a test environment.>
  21.  
  22. HTML::Mason::ApacheHandler2 was written to allow Mason to run in
  23. a 'pure' mod_perl2/Apache2 environment using the mod_perl2 native
  24. request structure as implemented by libapreq2. As such, this module
  25. is highly experimental and definitely not-ready-for-prime-time. This
  26. is an unofficial release, not supported by the Mason group. If you
  27. want to use this module in a testing environment, please address
  28. problems, issues, comments, and improvements to me, not Mason.
  29.  
  30. When deciding to port Mason to mod_perl2 I took the approach to add
  31. Module(s) rather than patching core Mason modules. Upon investigation
  32. I discovered that all the Apache 'glue' code in Mason was contained in
  33. HTML::Mason::ApacheHandler. Therefore, I renamed and modified that
  34. module to create HTML::Mason::ApacheHandler2.
  35.  
  36. The actual changes I made can be found in the distribution in
  37. B<diff/ApacheHandler.diff> ( made with 'diff -Naru' ... ).
  38.  
  39. As a result of my approach, you may install the normal Mason ( >= 1.25 ),
  40. the modules in L</"PREREQUISITES"> below, and this module. After configuring
  41. ( see L</"CONFIGURATION"> below ), you're ready to play.
  42.  
  43. The ApacheHandler2 object links Mason to mod_perl2, running components in
  44. response to HTTP requests. It is controlled primarily through
  45. parameters to the new() constructor.
  46.  
  47. handle_request() is not a user method, but rather is called from the
  48. HTML::Mason::handler() routine in handler.pl.
  49.  
  50. HTML::Mason::ApacheHandler2 is a modified copy of the standard
  51. HTML::Mason::ApacheHandler. ApacheHandler2 B<MUST> be used with mod_perl2.
  52.  
  53. You may, however, run Mason with Apache2/mod_perl2 without ApacheHandler2
  54. (see my rather dated mini-HOWTO at
  55. L<http://beaucox.com/mason/mason-with-apmp2-mini-HOWTO.htm>), but you then
  56. use use 'CGI' requests rather than the native
  57. 'mod_perl' requests.
  58.  
  59. The interface is the same as ApacheHandler's, Please refer to
  60. L<HTML::Mason>, L<HTML::Mason::ApacheHandler>, and
  61. L<http://masonhq.com/docs/manual/Admin.html>.
  62.  
  63. =head1 PREREQUISITES
  64.  
  65. You must have the following packages installed:
  66.  
  67.     perl            => 5.8.0
  68.     mod_perl        => 1.9910
  69.     HTML::Mason     => 1.25
  70.     libapreq2       => 2.02-dev
  71.  
  72. Please refer to the packages' documentation for instructions.
  73.  
  74. =head1 WARNING: PERL 5.8.2
  75.  
  76. If you are using perl 5.8.2 you may get a series of errors
  77. in the http/error_log such as:
  78.  
  79.     Attempt to free unreferenced scalar: SV 0x405e6e78
  80.      at /usr/lib/perl5/site_perl/5.8.2/HTML/Mason/Request.pm line 160.
  81.     ...
  82.     [Fri Jan 30 09:41:58 2004] [error] [client 207.175.219.202]
  83.      Attempt to free unreferenced scalar: SV 0x405e6e78
  84.      at /usr/lib/perl5/site_perl/5.8.2/i686-linux-thread-multi/
  85.      Apache/Cookie.pm line 67.
  86.   
  87.     Stack:
  88.       [/usr/lib/perl5/site_perl/5.8.2/HTML/Mason/ApacheHandler2.pm:892]
  89.       [/usr/lib/perl5/site_perl/5.8.2/HTML/Mason/ApacheHandler2.pm:801]
  90.       [/srv/www/perl/MyApache/Mason/ApacheHandler2.pm:86]
  91.       [-e:0]
  92.  
  93. which may return a 500 Internal Server Error to the user.
  94.  
  95. There was a bug introduced in perl 5.8.2 and fixed in 5.8.3, which affects 
  96. some XS modules running under a threaded mpm mod_perl 2.0 (or any ithreads 
  97. perl application). The affected modules can be fixed, to avoid this problem, 
  98. by using the PERL_NO_GET_CONTEXT macro in the XS code (see the perlguts 
  99. manpage for more information). So you need to check whether a newer version of 
  100. the module is available. If not you need to upgrade to perl 5.8.3 or higher 
  101. and the problem will go away.
  102.  
  103. When I had these problems, I ended up
  104. upgrading to 5.8.3 and B<recompiling EVERY CPAN module I use and
  105. remaking mod_perl2>. You may have to do the same thing.
  106.  
  107. I don't know if there are similar problems in 5.8.0 or 5.8.1,
  108. but I gather the problem is mainly manifested in 5.8.2.
  109.  
  110. =head1 CONFIGURATION
  111.  
  112. ApacheHandler2 provides a way for Mason to use the pure mod_perl2 request
  113. interface (libapreq2). B<THIS MODULE IS EXPERIMENTAL. PLEASE USE FOR
  114. TESTING ONLY UNTIL IT HAS PASSED THE TEST OF TIME.> Having given that
  115. dire warning, I have been using it on my personal site and one of the
  116. sites I administer since mid January, 2004. It _seems_ to work fine.
  117.  
  118. Configuring your Mason system may be done in many different ways;
  119. please refer to the Mason documentation, specifically, the Administrator's
  120. manual at
  121. L<http://masonhq.com/docs/manual/Admin.html>.
  122.  
  123. This section gives several sample configurations to get you started and
  124. notes the special configuration parameters that are
  125. B<required> for this module's operation with the native mod_perl2 interface.
  126.  
  127. All of the sample configuration files and scripts below can be
  128. found in the B<eg/> subdirectory of this distribution.
  129.  
  130. =head2 All Configuration in the 'httpd.conf' File
  131.  
  132. The sample httpd.conf file may be found at B<eg/httpd-mason-simple.conf>.
  133. You must, of course, change all path names below to suit your particular
  134. installation.
  135.  
  136. First, load the necessary mod_perl2 modules:
  137.  
  138.     LoadModule perl_module /usr/apache2/lib/apache/mod_perl.so
  139.     LoadModule apreq_module /usr/apache2/lib/apache/mod_apreq.so
  140.     LoadModule cgid_module /usr/apache2/lib/apache/mod_cgid.so
  141.  
  142. mod_perl2 is loaded as in the past. libapreg2 - the new mod_perl2-native
  143. request and cookie interface is loaded next. cgid is the optional
  144. CGI daemon module.
  145.  
  146. Next, load the modules your system requires:
  147.  
  148.     PerlModule Apache2
  149.     PerlSwitches -I/usr/local/test/httpd/perl
  150.     PerlModule Apache::Request
  151.     PerlModule Apache::Cookie
  152.     ...
  153.  
  154. 'PerlModule' is the configuration file syntax for perl's 'use';
  155. trim this list to suit your system (and conserve memory). The
  156. 'PerlSwitches' directive prepends the specified directory to
  157. perl's @INC array;
  158.  
  159. Setup the perl directory for your site:
  160.  
  161.     Alias /perl/ /usr/local/test/httpd/perl/
  162.     <Location /perl/>
  163.       SetHandler perl-script
  164.       PerlResponseHandler ModPerl::Registry
  165.       PerlOptions +ParseHeaders
  166.       Options +ExecCGI
  167.     </Location>
  168.  
  169. Now, configure Mason. First add the following perl variables
  170. B<which are required> for the operation of ApacheHandler2: 
  171.  
  172.     PerlSetVar _MasonUser wwwrun
  173.     PerlSetVar _MasonGroup nogroup
  174.     PerlSetVar _MasonDefaultDocumentRoot "/usr/local/test/httpd/htdocs"
  175.  
  176. '_MasonUser' and '_MasonGroup' specify the user/group under which
  177. Apache runs; they B<must> be the same as specified int the normal
  178. 'User' and 'Croup' directives earlier in your configuration file
  179. (this change was made necessary because $s->uid and $s->gid are
  180. not supported in mod_perl2
  181. - see L<http://perl.apache.org/docs/2.0/user/porting/compat.html#C__s_E_gt_uid_>).
  182.  
  183. '_MasonDefaultDocumentRoot' is required because the configuration
  184. directives are not available during server startup in mod_perl2.
  185. It should specify the 'DocumentRoot' directory specified earlier in
  186. your configuration file.
  187.  
  188. You may (optionally) pre-load any modules your Mason modules may
  189. require here - see
  190. L<http://masonhq.com/docs/manual/Admin.html#external_modules>.
  191. The '<Perl>...</Perl>' directives are used because
  192. this modules must be loaded within the HTML::Mason::Commands name space.
  193.  
  194.     <Perl>
  195.     {
  196.         package HTML::Mason::Commands;
  197.         use Apache::Const -compile => ':common';
  198.         ...
  199.     }
  200.     </Perl>
  201.  
  202. Finally, here is an example of a virtual host: 
  203.  
  204.     Listen 12984
  205.     NameVirtualHost localhost:12984
  206.  
  207.     # for general testing - default - on localhost
  208.  
  209.     # site: bctest
  210.     <VirtualHost localhost:12984>
  211.       ServerName bctest.beaucox.com
  212.       DocumentRoot "/usr/local/test/httpd/htdocs/bctest"
  213.       PerlSetVar MasonCompRoot /usr/local/test/httpd/htdocs/bctest
  214.       PerlSetVar MasonDataDir  /usr/local/test/httpd/mason/bctest
  215.       PerlSetVar MasonRequestClass          MasonX::Request::WithApacheSession2
  216.       PerlSetVar MasonSessionAllowInvalidId yes
  217.       PerlSetVar MasonSessionCookieName     beaucox-bctest-cookie
  218.       PerlSetVar MasonSessionCookieDomain   .beaucox.com
  219.       PerlSetVar MasonSessionCookieExpires  +7d
  220.       PerlSetVar MasonSessionClass          Apache::Session::MySQL
  221.       PerlSetVar MasonSessionDataSource     dbi:mysql:bctest_sessions
  222.       PerlSetVar MasonSessionUserName       mysql
  223.       PerlSetVar MasonSessionPassword       mysql
  224.       PerlSetVar MasonSessionLockDataSource dbi:mysql:bctest_sessions
  225.       PerlSetVar MasonSessionLockUserName   mysql
  226.       PerlSetVar MasonSessionLockPassword   mysql
  227.       PerlSetVar MasonSessionUseCookie      yes
  228.       <FilesMatch "^_">
  229.         SetHandler perl-script
  230.         PerlResponseHandler HTML::Mason::ApacheHandler2
  231.      </FilesMatch>
  232.      <Directory "/usr/local/test/httpd/htdocs/bctest">
  233.         <FilesMatch "\.html$|\.htm$">
  234.           SetHandler perl-script
  235.           PerlResponseHandler HTML::Mason::ApacheHandler2
  236.         </FilesMatch>
  237.       </Directory>
  238.     </VirtualHost>
  239.  
  240. In this example, the virtual host is using
  241. MasonX::Request::WithApacheSession2 (note the '2') - hence the
  242. 'MasonSession...' directives. Either modify them
  243. for your own use ( see L<MasonX::Request::WithApacheSession2> and
  244. L<MasonX::Request::WithApacheSession> or omit them
  245. if you are not using the session module.
  246. For mod_perl2 compatibility,
  247. 'PerlResponseHandler' is used instead of 'PerlHandler' - see
  248. L<http://perl.apache.org/docs/2.0/user/porting/compat.html#C_PerlHandler_>.
  249.  
  250. =head2 Configuration with Scripts
  251.  
  252. In this example, you must manage the http.conf file and two
  253. perl scripts; you gain superior flexibility in exchange for a little
  254. elbow grease.
  255.  
  256. =head3 httpd.conf
  257.  
  258. Here are the relevant sections of the httpd.conf file
  259. (the complete configuration file may be found at B<eg/httpd-mason.conf>):
  260.  
  261.     LoadModule perl_module /usr/apache2/lib/apache/mod_perl.so
  262.     LoadModule apreq_module /usr/apache2/lib/apache/mod_apreq.so
  263.     LoadModule cgid_module /usr/apache2/lib/apache/mod_cgid.so
  264.  
  265. Nothing new here, same as the configuration-file-only example above;
  266.  
  267.     PerlSetEnv MOD_PERL_INC    "/usr/local/test/httpd/perl"
  268.     PerlRequire "/usr/local/test/httpd/conf/startup2.pl"
  269.  
  270. The 'PerlSetEnv' directive is used so the startup scripts can be written
  271. without any 'hard' path dependences. The 'PerlRequire' runs the actual startup
  272. script whose name and location are of your choosing.
  273.  
  274.     Alias /perl/ /usr/local/test/httpd/perl/
  275.     <Location /perl/>
  276.       SetHandler perl-script
  277.       PerlResponseHandler ModPerl::Registry
  278.       PerlOptions +ParseHeaders
  279.       Options +ExecCGI
  280.     </Location>
  281.  
  282. Setup you perl directory as shown in the previous section.
  283.  
  284. Now to Mason:
  285.  
  286.     PerlSetVar _MasonUser wwwrun
  287.     PerlSetVar _MasonGroup nogroup
  288.     PerlSetVar _MasonDefaultDocumentRoot "/usr/local/test/httpd/htdocs"
  289.  
  290. The same as described in the previous section.
  291.  
  292.     PerlSetEnv MASON_COMP_ROOT    "/usr/local/test/httpd/htdocs"
  293.     PerlSetEnv MASON_DATA_ROOT    "/usr/local/test/httpd/mason"
  294.     PerlSetEnv MASON_SITES        "bctest:masontest"
  295.  
  296. We will see below how thews environment variables are used int the scripts
  297. below.
  298.  
  299. Finally, here is a sample virtual host:
  300.  
  301.     Listen 12984
  302.     NameVirtualHost localhost:12984
  303.  
  304.     # for general testing - default - on localhost
  305.  
  306.     <VirtualHost localhost:12984>
  307.       ServerName bctest.beaucox.com
  308.       DocumentRoot "/usr/local/test/httpd/htdocs/bctest"
  309.       PerlSetVar mason_site 'bctest'
  310.       <FilesMatch "^_">
  311.         SetHandler perl-script
  312.         PerlResponseHandler MyApache::Mason::ApacheHandler2
  313.       </FilesMatch>
  314.       <Directory "/usr/local/test/httpd/htdocs/bctest">
  315.         <FilesMatch "\.html$|\.htm$">
  316.           SetHandler perl-script
  317.           PerlResponseHandler MyApache::Mason::ApacheHandler2
  318.         </FilesMatch>
  319.       </Directory>
  320.     </VirtualHost>
  321.  
  322. Much like the virtual host described in the previous section, but
  323. much of the 'guts' are now filled in by the handler script below.
  324. Remember to specify 'PerlResponseHandler'.
  325.  
  326. =head3 startup2.pl
  327.  
  328. Here is the sample 'startup2.pl' script
  329. (found at B<eq/startup2.pl>):
  330.  
  331.     use Apache2 ();
  332.     use lib ( $ENV{MOD_PERL_INC} );
  333.     
  334.     use Apache::Request ();
  335.     use Apache::Cookie ();
  336.     use CGI ();
  337.     use CGI::Cookie ();
  338.     ...
  339.     use MyApache::Mason::ApacheHandler2 ();
  340.  
  341.     1;
  342.  
  343. Again, the modules you require are pre-loaded ('use'), and the
  344. the perl @INC array is adjusted. See how the use of the
  345. environment variable 'MOD_PERL_INC' - set in the httpd.conf -
  346. allows this script to be path-independent.
  347.  
  348. If you execute ('use') your Handler script here, the ApacheHandler2
  349. request objects are pre-loaded; otherwise they are loaded 'on the fly'.
  350. Refer the the discussion at
  351. L<http://masonhq.com/docs/manual/Admin.html#wrappers_with_virtual_hosts>.
  352.  
  353. =head3 ApacheHandler2.pm
  354.  
  355. Here is the sample 'MyApache::ApacheHandler2.pm' script. The full
  356. sample script may be found at B<eq/ApacheHandler2.pm>. It should be
  357. installed under B<your-perl-directory/Mason/ApacheHandler2> on your system;
  358. i.e:,
  359. in my case at: B</usr/local/test/httpd/perl/Mason/ApacheHandler2.pm>.
  360.  
  361.     #!/usr/bin/perl
  362.  
  363.     package MyApache::Mason::ApacheHandler2;
  364.  
  365.     use strict;
  366.     use warnings;
  367.  
  368. Pretty standard perl startup stuff.
  369.  
  370.     use Apache2 ();
  371.     use lib ( $ENV{MOD_PERL_INC} );
  372.  
  373.     use Apache::Request ();
  374.     use Apache::Cookie ();
  375.     use CGI ();
  376.     use CGI::Cookie ();
  377.  
  378. Includes you may need;
  379.  
  380.     our %ah = ();
  381.  
  382. This is a global hash that will hold, one for each site,
  383. ApacheHandler2's.
  384.  
  385.     #    Mason w/Apache support
  386.     use HTML::Mason::ApacheHandler2;
  387.  
  388.     #    Modules my components will use
  389.     {
  390.         package HTML::Mason::Commands;
  391.      
  392.         use Apache::Const -compile => ':common';
  393.         ...
  394.     }
  395.  
  396. Any includes you may want to pre-load for your Mason components.
  397.  
  398.     setup_sites();
  399.  
  400. This line, if present, will pre-load all the ApacheHandler2's (one for
  401. each site) at server startup time.
  402.  
  403. Now to handle the request:
  404.  
  405.     #  actual request handler
  406.     sub handler
  407.     {
  408.       my ($r) = @_;
  409.  
  410.       # DON'T allow internal components (starting with '_')
  411.       my $fn = $r->filename;
  412.       if ($fn =~ m{.*/(.*)} && $1 && $1 =~ /^_/) {
  413.         my $rip = $r->connection->remote_ip;
  414.         $r->log_error ("attempt to access internal component: $fn remote ip: $rip\n");
  415.         return Apache::NOT_FOUND;
  416.       }
  417.  
  418. A check to prevent outside direct access to internal Mason components -
  419. in my system, components that start with '_'.
  420.  
  421.       # allow only text/xxx content type
  422.         return -1 if $r->content_type && $r->content_type !~ m|^text/|i;
  423.  
  424. Skip Mason processing for non-text items (images, binary downloads, etc.)
  425.  
  426.       # find site and handler: dispatch request
  427.       my $site = $r->dir_config ('mason_site');
  428.  
  429.       unless( $site ) {
  430.          $r->log_error ("no 'mason_site' specified\n");
  431.          return Apache::NOT_FOUND;
  432.       }
  433.  
  434. If there is no site configured with 'PserSetVar mason_site xxx',
  435. you have boo-boo-ed and the request is logged and rejected. You could
  436. force a more noticeable alert, i.e. an email, if you really want to
  437. know when this happens, but you really should be able to prevent these
  438. error with adequate testing.
  439.  
  440.       unless( $ah{$site} ) {
  441.         setup_sites( $r, $site );
  442.         unless( $ah{$site} ) {
  443.           $r->log_error ("no 'ah' found for 'mason_site' $site\n");
  444.           return Apache::NOT_FOUND;
  445.         }
  446.       }
  447.  
  448. Here we check the the ApacheHandler2 is loaded, and load it if not; Of that
  449. does not work, you've got problems.
  450.  
  451.       my $status = $ah{$site}->handle_request ($r);
  452.  
  453. Finally! The request is sent on it's way.
  454.  
  455.       # special error handling here (email, etc...)
  456.  
  457. You could check the status here and do extra fancy error reporting here...
  458.  
  459.       $status;
  460.     }
  461.  
  462. Return the status and exit.
  463.  
  464. Now, here is where the ApacheHandler2 requests are loaded, either
  465. at startup time or on the fly.
  466.  
  467.     # set up an ApacheHandler2 for each site
  468.     sub setup_sites
  469.     {
  470.       my ( $r, $site ) = shift;
  471.       my @asites = ();
  472.       if( $site ) {
  473.         push @asites, $site;
  474.       } else {
  475.         my $sites = $ENV{MASON_SITES};
  476.         return unless $sites;
  477.         @asites = split /:/, $sites;
  478.       }
  479.       for my $site( @asites ) {
  480.         next if $ah{$site};
  481.         my @args =
  482.         (
  483.           args_method   => "mod_perl",
  484.           comp_root     => $ENV{MASON_COMP_ROOT}."/$site",
  485.           data_dir      => $ENV{MASON_DATA_ROOT}."/$site",
  486.           error_mode    => 'output',
  487.           request_class =>'MasonX::Request::WithApacheSession2',
  488.           session_allow_invalid_id => 'yes',
  489.           ...
  490.         );
  491.         push @args, $r if $r;
  492.         $ah{$site} = new HTML::Mason::ApacheHandler2( @args );
  493.       }
  494.     }
  495.  
  496.     1;
  497.  
  498. If your sites ApacheHandler2s are being setup 'on-the-fly', this
  499. method is called as 'setup_sites( $r, $site );'. Only that site
  500. is loaded.
  501.  
  502. On the other hand, if the sites are all loaded at server start as
  503. follows:
  504.  
  505. The 'MASON_SITES' environment variable, set in the httpd.conf
  506. file, consists of a list of site names separated by ':'s. This trick
  507. is used so the sites served may be changed in one place, the
  508. httpd.conf file, without having to update this script too
  509.  
  510. Note the use of the native mod_perl2 args_method: 'mod_perl'.
  511. Again, the environment variables set int the httpd.conf file are used her
  512. to keep this script path-independent.
  513.  
  514. This example is using the session subclass 'MasonX::With::ApacheSession2';
  515. modify or omit these statements.
  516.  
  517. =head1 STRESS TESTING
  518.  
  519. To see if your server works under load, you must do some stress testing.
  520. There are several Apache Test modules on CPAN, but if you are lazy
  521. ( like me ), you may
  522. try my simple test scripts.
  523.  
  524. =head2 stress.pl
  525.  
  526. A stress script is in the HTML::Mason::ApacheHandler2 distribution at
  527. B<scripts/stress.pl>. This simple perl script, which requires LWP::UserAgent
  528. in libwww, repeatedly gets a uri on you server and checks the result.
  529. Usage:
  530.  
  531.     perl stress.pl <uri-to-a-page-on-your-test-server> [repeat-count]
  532.  
  533. If the repeat count is missing, the test is endless ( stop it with
  534. ^C ).
  535.  
  536. =head2 httpd-mem,pl
  537.  
  538. To check for memory leaks, try B<scripts/httpd-mem.pl>. This script finds
  539. all the processes running for your server and totals the memory usage
  540. using the '/proc/<pid>/status' pseudo-files. This script will only work on
  541. systems with the GNU-Linux /proc file system.
  542.  
  543. Usage:
  544.  
  545.     perl httpd-mem.pl [id-for-ps]
  546.  
  547. Where [id-for-ps] is a string to select your test server pids from the
  548. ps aux command. The default is 'httpd -k'.
  549.  
  550. Every two seconds a line is
  551. printed to the terminal and B<httpd-mem.log>:
  552.  
  553.      VmData      VmExe      VmLck      VmLib      VmRSS     VmSize      VmStk
  554.     4297576      32248          0     524944    1479132    4904200       2784
  555.     4297576      32248          0     524944    1479132    4904200       2784
  556.     4297576      32248          0     524944    1479132    4904200       2784
  557.     ...
  558.  
  559. Check this output when running the stress test above to see if anything
  560. ( especially VmSize ) is growing; that _may_ indicate a memory leak.
  561.  
  562. =head1 mod_perl2 ALL THE WAY
  563.  
  564. If you want to take the next step, making a pure mod_perl2 site,
  565. you should:
  566.  
  567. =over 4
  568.  
  569. =item remake and install mod_perl
  570.  
  571. Disable global mod_perl backward compatibility by adding the
  572. 'MP_COMPAT_1X=0' flag to 'Makefile.PL':
  573.  
  574.  perl Makefile.PL MP_APXS=/where/ever MP_COMPAT_1X=0
  575.  
  576. This flag is ON by default.
  577.  
  578. =item grep your site for Apache::compat
  579.  
  580. Remove 'use Apache::compat' from all of your mod_perl modules; you may
  581. have to rework them to bring them up to speed. Stas and the guys
  582. at mod_perl have several excellent 1.x => 2.x porting documents,
  583. my personal favorite being
  584. L<http://perl.apache.org/docs/2.0/user/porting/compat.html>.
  585.  
  586. =item update your http.conf file
  587.  
  588. Once you have removed 1.x backward compatibility, you must bring
  589. your http.conf directives up to mod_perl2 standards as shown in
  590. L<http://perl.apache.org/docs/2.0/user/porting/compat.html#Configuration_Files_Porting>.
  591.  
  592. Some of the changes you will have to make are:
  593.  
  594.     PerlHandler        => PerlResponseHandler.
  595.   
  596.     PerlSendHeader On  => PerlOptions +ParseHeaders
  597.     PerlSendHeader Off => PerlOptions -ParseHeaders
  598.  
  599.     PerlSetupEnv On    => PerlOptions +SetupEnv
  600.     PerlSetupEnv Off   => PerlOptions -SetupEnv
  601.  
  602.     PerlTaintCheck     => PerlSwitches -T
  603.     PerlWarn           => PerlSwitches -w
  604.  
  605.     PerlFreshRestart   => is a mod_perl 1.0 legacy => see docs.
  606.  
  607. =back
  608.  
  609. I found this to be a snap, but then I started coding with mod_perl2;
  610. I suppose the port could be a bear if you have a mature site with lots of
  611. 1.x modules.
  612.  
  613. =head1 DON'T
  614.  
  615. =over 4
  616.  
  617. =item Mix and Match normal MasonX::... modules with HTML::Mason::ApacheHandler2
  618.  
  619. Any MasonX... modules that use ( subclass ) HTML::Mason::ApacheHandler
  620. will B<NOT> work in your pure mod_perl2 environment. Let me know ( or
  621. change them yourself ) when you want to use one I have not changed.
  622.  
  623. =item Bother the Mason developers with questions, etc.
  624.  
  625. HTML::Mason::ApacheHandler2 is unofficial and was written and is supported
  626. by me, not the Mason developers. Talk to me ( <mason@beaucox.com> ).
  627.  
  628. =back
  629.  
  630. =head1 DO
  631.  
  632. =over 4
  633.  
  634. =item Try it!
  635.  
  636. Setup a test server and see if the pure mod_perl2 Mason works for you.
  637.  
  638. =item Tell me what you think
  639.  
  640. Let me know your reaction to this effort. I welcome comments, suggestions,
  641. bug reports, and, yes, even mild flames.
  642.  
  643. =back
  644.  
  645. =head1 TODO
  646.  
  647. =over 4
  648.  
  649. =item Build tests
  650.  
  651. Currently, there are no 'real' tests defined in 'make test'. I
  652. plan to design and build some. Until then, the testing is
  653. left to you. Sorry :)
  654.  
  655. =item Continue to monitor my web site for problems
  656.  
  657. I am running this module at my web site ( L<http://beaucox.com> ). I
  658. am continually monitoring the site logs and memory usage to catch
  659. and correct any bugs I find.
  660.  
  661. =item Investigate Other MasonX:: modules that may have to be converted
  662.  
  663. The MasonX:: modules that currently tie to ApacheHandler must be reworked
  664. to operate with ApacheHandler2; I will attack those on demand. Please
  665. let me know.
  666.  
  667. =back
  668.  
  669. =head1 BUGS
  670.  
  671. Too early to tell; they are bound to come in as people give it a try.
  672.  
  673. =head1 AUTHOR
  674.  
  675. Beau E. Cox <mason@beaucox.com> L<http://beaucox.com>.
  676.  
  677. The real authors (I just made mod_perl2 changes) are the Mason crew, including:
  678. Jonathan Swartz <swartz@pobox.com>,
  679. Dave Rolsky <autarch@urth.org>,
  680. Ken Williams <ken@mathforum.org>.
  681.  
  682. Version 0.01 as of January, 2004.
  683.  
  684. =head1 SEE ALSO
  685.  
  686. My documents, including:
  687. L<HTML::Mason::ApacheHandler2|ApacheHandler2>,
  688. L<MasonX::Request::WithApacheSession2|WithApacheSession2>,
  689. L<MasonX::Request::WithMultiSession2|WithMultiSession2>,
  690.  
  691. Original Mason documents, including:
  692. L<HTML::Mason::ApacheHandler|ApacheHandler>,
  693. L<MasonX::Request::WithApacheSession|WithApacheSession>,
  694. L<MasonX::Request::WithMultiSession|WithMultiSession>.
  695.  
  696. Also see the Mason documentation at L<http://masonhq.com/docs/manual/>.
  697.  
  698.