1Catalyst::Manual::DeploUysmeerntC:o:nCAtaprtaiacblhuyets:et:d:m:oPMdea_rnpluearDllo:(c:3uD)meepnltoaytmieonnt::Apache::mod_perl(3)
2
3
4

NAME

6       Catalyst::Manual::Deployment::Apache::mod_perl - Deploying Catalyst
7       with mod_perl
8

mod_perl Deployment

10       The recommended method of deploying Catalyst applications is FastCGI.
11       In many cases, mod_perl is not the best solution, but we'll list some
12       pros and cons so you can decide for yourself.
13
14   Pros
15       Speed
16
17       mod_perl is fast, and your entire app will be loaded in memory within
18       each Apache process.
19
20       Shared memory for multiple apps
21
22       If you need to run several Catalyst apps on the same server, mod_perl
23       will share the memory for common modules.
24
25   Cons
26       Memory usage
27
28       Since your application is fully loaded in memory, every Apache process
29       will be rather large.  This means a large Apache process will be tied
30       up while serving static files, large files, or dealing with slow
31       clients.  For this reason, it is best to run a two-tiered web
32       architecture with a lightweight frontend server passing dynamic
33       requests to a large backend mod_perl server.
34
35       Reloading
36
37       Any changes made to the code of your app require a full restart of
38       Apache. Catalyst does not support Apache::Reload or StatINC. This is
39       another good reason to run a frontend web server where you can set up
40       an "ErrorDocument 502" page to report that your app is down for
41       maintenance.
42
43       Cannot run multiple versions of the same app
44
45       It is not possible to run two different versions of the same
46       application in the same Apache instance because the namespaces will
47       collide.
48
49       Cannot run different versions of libraries
50
51       If you have two different applications which run on the same machine,
52       and each application needs a different versions of a library, the only
53       way to do this is to have per-vhost perl interpreters (with different
54       library paths). This is entirely possible, but nullifies all the memory
55       sharing benefits that you get from having multiple applications sharing
56       the same interpreter.
57

Setup

59       Now that we have that out of the way, let's talk about setting up
60       mod_perl to run a Catalyst app.
61
62   2. Install Apache with mod_perl
63       Both Apache 1.3 and Apache 2 are supported, although Apache 2 is highly
64       recommended.  With Apache 2, make sure you are using the prefork MPM
65       and not the worker MPM.  The reason for this is that many Perl modules
66       are not thread-safe and may have problems running within the threaded
67       worker environment.  Catalyst is thread-safe however, so if you know
68       what you're doing, you may be able to run using worker.
69
70       In Debian, the following commands should get you going.
71
72           apt-get install apache2-mpm-prefork
73           apt-get install libapache2-mod-perl2
74
75   3. Configure your application
76       Every Catalyst application will automagically become a mod_perl handler
77       when run within mod_perl.  This makes the configuration extremely easy.
78       Here is a basic Apache 2 configuration.
79
80           PerlSwitches -I/var/www/MyApp/lib
81           PerlModule MyApp
82
83           <Location />
84               SetHandler          modperl
85               PerlResponseHandler MyApp
86           </Location>
87
88       The most important line here is "PerlModule MyApp".  This causes
89       mod_perl to preload your entire application into shared memory,
90       including all of your controller, model, and view classes and
91       configuration.  If you have -Debug mode enabled, you will see the
92       startup output scroll by when you first start Apache.
93
94       Also, there have been reports that the block above should instead be
95       (but this has not been confirmed):
96
97           <Perl>
98               use lib '/var/www/MyApp/lib';
99               use MyApp;
100           </Perl>
101
102           <Location />
103               SetHandler          modperl
104               PerlResponseHandler MyApp
105           </Location>
106
107       For an example Apache 1.3 configuration, please see the documentation
108       for Catalyst::Engine::Apache::MP13.
109
110   Test It
111       That's it, your app is now a full-fledged mod_perl application!  Try it
112       out by going to http://your.server.com/.
113

Other Options

115   Non-root location
116       You may not always want to run your app at the root of your server or
117       virtual host.  In this case, it's a simple change to run at any non-
118       root location of your choice.
119
120           <Location /myapp>
121               SetHandler          modperl
122               PerlResponseHandler MyApp
123           </Location>
124
125       When running this way, it is best to make use of the "uri_for" method
126       in Catalyst for constructing correct links.
127
128   Static file handling
129       Static files can be served directly by Apache for a performance boost.
130
131           DocumentRoot /var/www/MyApp/root
132           <Location /static>
133               SetHandler default-handler
134           </Location>
135
136       This will let all files within root/static be handled directly by
137       Apache.  In a two-tiered setup, the frontend server should handle
138       static files.  The configuration to do this on the frontend will vary.
139
140       Note the path of the application needs to be stated explicitly in the
141       web server configuration for this recipes.
142

AUTHORS

144       Catalyst Contributors, see Catalyst.pm
145
147       This library is free software. You can redistribute it and/or modify it
148       under the same terms as Perl itself.
149
150
151
152perl v5.34.0                 Catal2y0s2t1:-:0M7a-n2u2al::Deployment::Apache::mod_perl(3)
Impressum