1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
0bin/docs/.build/html/en/apache_install.html
2015-05-10 19:53:55 +02:00

213 lines
10 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Apache setup &mdash; 0bin 0.1 documentation</title>
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="0bin 0.1 documentation" href="../index.html" />
<link rel="next" title="Nginx setup" href="nginx_install.html" />
<link rel="prev" title="Easiest installation" href="easy_install.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="nginx_install.html" title="Nginx setup"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="easy_install.html" title="Easiest installation"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">0bin 0.1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="apache-setup">
<h1>Apache setup<a class="headerlink" href="#apache-setup" title="Permalink to this headline"></a></h1>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You need to have followed the <a class="reference internal" href="easy_install.html"><em>easy install</em></a> first.</p>
</div>
<p>Apache is heavier than <a class="reference internal" href="nginx_install.html"><em>Nginx</em></a>. But it&#8217;s also much more famous:</p>
<ul class="simple">
<li>more people will be able to help you on forums;</li>
<li>your hosting will most probably support Apache;</li>
<li>the configuration file syntax is familiar to a lot of people.</li>
</ul>
<p>An Apache setup is still much more robust and secure than an easy installation.</p>
<p>Une installation apache est aussi beaucoup plus solide et sécurisé qu&#8217;une
installation facile. You&#8217;ll benefit from having:</p>
<ul class="simple">
<li>the possibility to have several projects listening to the port 80;</li>
<li>several Apache module at your disposal (like requests throttling);</li>
<li>Apache robustness in front end: it&#8217;s secure, and there is much less chance
it will crash under heavy load;</li>
<li>your web site processes won&#8217;t run with admin rights, even if
<a class="reference internal" href="options.html#user-and-group-en"><span>&#8211;user</span></a> doesn&#8217;t
work on your OS.</li>
</ul>
<div class="section" id="mod-wsgi">
<h2>Mod_wsgi<a class="headerlink" href="#mod-wsgi" title="Permalink to this headline"></a></h2>
<p>The modern Web Python servers all work the same way, following an norm for
interfacing: WSGI.</p>
<p>This is the most performante solution, and the best to use. But it will require
the setup of the Apache module mod_wsgi. If you don&#8217;t know how to do this, or
if you can&#8217;t do it (E.G: your hosting won&#8217;t let you), you need to go for
the CGI setup.</p>
<p>First, make sure you have mod_wsgi installed and enable by running (as admin):</p>
<div class="highlight-python"><div class="highlight"><pre>a2enmod wsgi
</pre></div>
</div>
<p>This enable mod_wsgi. It it doesn&#8217;t, install it first (on ubuntu, the package
is libapache2-mod-wsgi).</p>
<p>Then create an Apache configuration file, usually in /etc/apache/sites-available/.
Name it zerobin:</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;VirtualHost *:80&gt;
ServerName www.yourwebsite.com
WSGIDaemonProcess zerobin user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias / /path/to/zerobin/app.wsgi
&lt;Directory /path/to/zerobin/zerobin/&gt;
WSGIProcessGroup zerobin
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
&lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre></div>
</div>
<p>Activate the website (as admin):</p>
<div class="highlight-python"><div class="highlight"><pre>a2ensite zerobin
</pre></div>
</div>
<p>And reload the apache configuration (as admin):</p>
<div class="highlight-python"><div class="highlight"><pre>service apache2 reload
</pre></div>
</div>
<p>You&#8217;ll note that we refer to a file named app.wsgi. It&#8217;s a Python file
creating the application Apache is going to use to start the Python process:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">sys</span>
<span class="c"># make sure the zerobin module is in the PYTHON PATH and importable</span>
<span class="n">ZEROBIN_PARENT_DIR</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">__file__</span><span class="p">))</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">ZEROBIN_PARENT_DIR</span><span class="p">)</span>
<span class="c"># create the wsgi callable</span>
<span class="kn">from</span> <span class="nn">zerobin.routes</span> <span class="kn">import</span> <span class="n">get_app</span>
<span class="n">settings</span><span class="p">,</span> <span class="n">application</span> <span class="o">=</span> <span class="n">get_app</span><span class="p">(</span><span class="n">compressed_static</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
<p>You can of course create your own, as the <cite>get_app</cite> function is the only
way to pass settings to 0bin with this setup. You would do this by creating
a configuration file and passing it to the function:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">sys</span>
<span class="n">ZEROBIN_PARENT_DIR</span> <span class="o">=</span> <span class="s">&#39;/path/to/zerobin/parent/dir&#39;</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">ZEROBIN_PARENT_DIR</span><span class="p">)</span>
<span class="kn">from</span> <span class="nn">zerobin.routes</span> <span class="kn">import</span> <span class="n">get_app</span>
<span class="n">settings</span><span class="p">,</span> <span class="n">application</span> <span class="o">=</span> <span class="n">get_app</span><span class="p">(</span><span class="n">settings_file</span><span class="o">=</span><span class="s">&#39;/path/to/settings.py&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="cgi">
<h2>CGI<a class="headerlink" href="#cgi" title="Permalink to this headline"></a></h2>
<p>You can also run 0bin using CGI, but infortunaly we didn&#8217;t have time to cover
it yet. Please contact us if you ever get the need to use it.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Apache setup</a><ul>
<li><a class="reference internal" href="#mod-wsgi">Mod_wsgi</a></li>
<li><a class="reference internal" href="#cgi">CGI</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="easy_install.html"
title="previous chapter">Easiest installation</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="nginx_install.html"
title="next chapter">Nginx setup</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/en/apache_install.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="nginx_install.html" title="Nginx setup"
>next</a> |</li>
<li class="right" >
<a href="easy_install.html" title="Easiest installation"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">0bin 0.1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&copy; Copyright 2012, Sam et Max.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.1.
</div>
</body>
</html>