configplack.html 9.1 KB
Newer Older
Xavier Guimard's avatar
Xavier Guimard committed
1 2 3 4 5 6
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="utf-8" />
  <title>documentation:2.0:configplack</title>
<meta name="generator" content="DokuWiki"/>
Xavier Guimard's avatar
Xavier Guimard committed
7
<meta name="robots" content="index,follow"/>
Xavier Guimard's avatar
Xavier Guimard committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
<meta name="keywords" content="documentation,2.0,configplack"/>
<link rel="search" type="application/opensearchdescription+xml" href="lib/exe/opensearch.html" title="LemonLDAP::NG"/>
<link rel="start" href="configplack.html"/>
<link rel="contents" href="configplack.html" title="Sitemap"/>
<link rel="stylesheet" type="text/css" href="lib/exe/css.php.t.bootstrap3.css"/>
<!-- //if:usedebianlibs
  <link rel="stylesheet" type="text/css" href="/javascript/bootstrap/css/bootstrap.min.css" />
//elsif:useexternallibs
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></script>
//elsif:cssminified
  <link rel="stylesheet" type="text/css" href="/static/bwr/bootstrap/dist/css/bootstrap.min.css" />
//else -->
  <link rel="stylesheet" type="text/css" href="/static/bwr/bootstrap/dist/css/bootstrap.css" />
<!-- //endif -->
<script type="text/javascript">/*<![CDATA[*/var NS='documentation:2.0';var JSINFO = {"id":"documentation:2.0:configplack","namespace":"documentation:2.0"};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="lib/exe/js.php.t.bootstrap3.js"></script>
<!-- //if:usedebianlibs
<script type="text/javascript" src="/javascript/jquery/jquery.min.js"></script>
//elsif:useexternallibs
<script type="text/javascript" src="http://code.jquery.com/jquery-2.2.0.min.js"></script>
//elsif:jsminified
<script type="text/javascript" src="/static/bwr/jquery/dist/jquery.min.js"></script>
//else -->
<script type="text/javascript" src="/static/bwr/jquery/dist/jquery.js"></script>
<!-- //endif -->
<!-- //if:usedebianlibs
  <script type="text/javascript" src="/javascript/jquery-ui/jquery-ui.min.js"></script>
//elsif:useexternallibs
  <script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
//elsif:jsminified
  <script type="text/javascript" src="/static/bwr/jquery-ui/jquery-ui.min.js"></script>
//else -->
  <script type="text/javascript" src="/static/bwr/jquery-ui/jquery-ui.js"></script>
<!-- //endif -->
</head>
<body>
<div class="dokuwiki export container">

<h1 class="sectionedit1" id="deploy_lemonldapng_on_a_plack_server">Deploy LemonLDAP::NG on a Plack server</h1>
<div class="level1">

<p>
Xavier Guimard's avatar
Xavier Guimard committed
51
<a href="https://metacpan.org/release/Plack" class="urlextern" title="https://metacpan.org/release/Plack"  rel="nofollow">Plack</a> is a powerful engine that powers many very fast <a href="http://plackperl.org/#servers" class="urlextern" title="http://plackperl.org/#servers"  rel="nofollow">servers</a>. LLNG uses some Plack libraries to run as FastCGI server. So, It can be easily run on these servers. See also <a href="psgi.html" class="wikilink1" title="documentation:2.0:psgi">Advanced PSGI usage</a> if you want to replace LLNG FastCGI server.
Xavier Guimard's avatar
Xavier Guimard committed
52 53 54
</p>

</div>
Xavier Guimard's avatar
Xavier Guimard committed
55
<!-- EDIT1 SECTION "Deploy LemonLDAP::NG on a Plack server" [1-373] -->
Xavier Guimard's avatar
Xavier Guimard committed
56 57
<h2 class="sectionedit2" id="complete_example">Complete example</h2>
<div class="level2">
Xavier Guimard's avatar
Xavier Guimard committed
58 59 60
<dl class="file">
<dt><a href="_export/code/documentation/2.0/configplack/codeblock.0.code" title="Download Snippet" class="mediafile mf_psgi">llapp.psgi</a></dt>
<dd><pre class="code file perl"><span class="co1">#!/usr/bin/perl</span>
Xavier Guimard's avatar
Xavier Guimard committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
&nbsp;
<span class="kw2">use</span> Data<span class="sy0">::</span><span class="me2">Dumper</span><span class="sy0">;</span>
<span class="kw2">use</span> Plack<span class="sy0">::</span><span class="me2">Builder</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Basic test app</span>
<span class="kw1">my</span> <span class="re0">$testApp</span> <span class="sy0">=</span> <span class="kw2">sub</span> <span class="br0">&#123;</span>
    <span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$env</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="co5">@_</span><span class="sy0">;</span>
    <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="br0">&#91;</span>
        <span class="nu0">200</span><span class="sy0">,</span>
        <span class="br0">&#91;</span> <span class="st_h">'Content-Type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/plain'</span> <span class="br0">&#93;</span><span class="sy0">,</span>
        <span class="br0">&#91;</span> <span class="st0">&quot;Hello LLNG world<span class="es0">\n</span><span class="es0">\n</span>&quot;</span> <span class="sy0">.</span> Dumper<span class="br0">&#40;</span><span class="re0">$env</span><span class="br0">&#41;</span> <span class="br0">&#93;</span><span class="sy0">,</span>
    <span class="br0">&#93;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Build protected app</span>
<span class="kw1">my</span> <span class="re0">$test</span> <span class="sy0">=</span> builder <span class="br0">&#123;</span>
    enable <span class="st0">&quot;Auth::LemonldapNG&quot;</span><span class="sy0">;</span>
    <span class="re0">$testApp</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Build portal app</span>
<span class="kw2">use</span> Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Portal</span><span class="sy0">::</span><span class="me2">Main</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="re0">$portal</span> <span class="sy0">=</span> builder <span class="br0">&#123;</span>
    enable <span class="st0">&quot;Plack::Middleware::Static&quot;</span><span class="sy0">,</span>
      path <span class="sy0">=&gt;</span> <span class="st_h">'^/static/'</span><span class="sy0">,</span>
      root <span class="sy0">=&gt;</span> <span class="st_h">'/path/to/portal/htdocs/'</span><span class="sy0">;</span>
    Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Portal</span><span class="sy0">::</span><span class="me2">Main</span><span class="sy0">-&gt;</span><span class="me1">run</span><span class="br0">&#40;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Build manager app</span>
<span class="kw2">use</span> Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Manager</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="re0">$manager</span> <span class="sy0">=</span> builder <span class="br0">&#123;</span>
    enable <span class="st0">&quot;Plack::Middleware::Static&quot;</span><span class="sy0">,</span>
      path <span class="sy0">=&gt;</span> <span class="st_h">'^/static/'</span><span class="sy0">,</span>
      root <span class="sy0">=&gt;</span> <span class="st_h">'/path/to/manager/htdocs/'</span><span class="sy0">;</span>
    enable <span class="st0">&quot;Plack::Middleware::Static&quot;</span><span class="sy0">,</span>
      path <span class="sy0">=&gt;</span> <span class="st_h">'^/doc/'</span><span class="sy0">,</span>
      root <span class="sy0">=&gt;</span> <span class="st_h">'/path/to/dir/that/contains/&quot;doc&quot;'</span><span class="sy0">;</span>
    enable <span class="st0">&quot;Plack::Middleware::Static&quot;</span><span class="sy0">,</span>
      path <span class="sy0">=&gt;</span> <span class="st_h">'^/lib/'</span><span class="sy0">,</span>
      root <span class="sy0">=&gt;</span> <span class="st_h">'/path/to/doc/pages/documentation/current/'</span><span class="sy0">;</span>
    Lemonldap<span class="sy0">::</span><span class="me2">NG</span><span class="sy0">::</span><span class="me2">Manager</span><span class="sy0">-&gt;</span><span class="me1">run</span><span class="br0">&#40;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Global app</span>
builder <span class="br0">&#123;</span>
    mount <span class="st_h">'http://test1.example.com/'</span>   <span class="sy0">=&gt;</span> <span class="re0">$test</span><span class="sy0">;</span>
    mount <span class="st_h">'http://auth.example.com/'</span>    <span class="sy0">=&gt;</span> <span class="re0">$portal</span><span class="sy0">;</span>
    mount <span class="st_h">'http://manager.example.com/'</span> <span class="sy0">=&gt;</span> <span class="re0">$manager</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span></pre>
Xavier Guimard's avatar
Xavier Guimard committed
111
</dd></dl>
Xavier Guimard's avatar
Xavier Guimard committed
112 113 114 115 116 117 118

<p>
Launch it with <a href="https://github.com/miyagawa/Starman" class="urlextern" title="https://github.com/miyagawa/Starman"  rel="nofollow">Starman</a> for example:
</p>
<pre class="code :bash"><span class="co4">$ </span>starman <span class="re5">--port</span> <span class="nu0">80</span> <span class="re5">--workers</span> <span class="nu0">32</span> llapp.psgi</pre>

</div>
Xavier Guimard's avatar
Xavier Guimard committed
119
<!-- EDIT2 SECTION "Complete example" [374-] --></div>
Xavier Guimard's avatar
Xavier Guimard committed
120 121
</body>
</html>