2012-05-07 17:08:58 +04:00
|
|
|
|
|
|
|
|
|
|
|
<!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" />
|
|
|
|
|
2012-05-18 16:29:52 +04:00
|
|
|
<title>Apache setup — 0bin 0.1 documentation</title>
|
2012-05-07 17:08:58 +04:00
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/default.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" />
|
2012-05-18 16:29:52 +04:00
|
|
|
<link rel="next" title="Nginx setup" href="nginx_install.html" />
|
|
|
|
<link rel="prev" title="Easiest installation" href="easy_install.html" />
|
2012-05-07 17:08:58 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="related">
|
|
|
|
<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" >
|
2012-05-18 16:29:52 +04:00
|
|
|
<a href="nginx_install.html" title="Nginx setup"
|
2012-05-07 17:08:58 +04:00
|
|
|
accesskey="N">next</a> |</li>
|
|
|
|
<li class="right" >
|
2012-05-18 16:29:52 +04:00
|
|
|
<a href="easy_install.html" title="Easiest installation"
|
2012-05-07 17:08:58 +04:00
|
|
|
accesskey="P">previous</a> |</li>
|
|
|
|
<li><a href="../index.html">0bin 0.1 documentation</a> »</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="document">
|
|
|
|
<div class="documentwrapper">
|
|
|
|
<div class="bodywrapper">
|
|
|
|
<div class="body">
|
|
|
|
|
2012-05-18 16:29:52 +04:00
|
|
|
<div class="section" id="apache-setup">
|
|
|
|
<h1>Apache setup<a class="headerlink" href="#apache-setup" title="Permalink to this headline">¶</a></h1>
|
2012-05-19 00:47:17 +04:00
|
|
|
<p>Apache is heavier than <a class="reference internal" href="nginx_install.html"><em>Nginx</em></a>. But it’s also much more famous:</p>
|
2012-05-18 16:29:52 +04:00
|
|
|
<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’une
|
|
|
|
installation facile. You’ll benefit from having:</p>
|
|
|
|
<ul class="simple">
|
|
|
|
<li>the possiblity 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’s secure, and there is much less chance
|
|
|
|
it will crash under heavy load;</li>
|
2012-05-19 00:47:17 +04:00
|
|
|
<li>your web site processes won’t run with admin rights, even if
|
|
|
|
<a class="reference internal" href="options.html#user-and-group-en"><em>–user</em></a> doesn’t
|
2012-05-18 16:29:52 +04:00
|
|
|
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’t know how to do this, or
|
|
|
|
if you can’t do it (E.G: your hosting won’t let you), you need to go for
|
|
|
|
the CGI setup.</p>
|
2012-05-19 00:18:40 +04:00
|
|
|
<p>First, make sure you have mod_wsgi installed and enable by running (as admin):</p>
|
|
|
|
<div class="highlight-python"><pre>a2enmod wsgi</pre>
|
|
|
|
</div>
|
|
|
|
<p>This enable mod_wsgi. It it doesn’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"><pre><VirtualHost *:80>
|
|
|
|
ServerName www.yourwebsite.com
|
|
|
|
|
|
|
|
WSGIDaemonProcess zerobin user=www-data group=www-data processes=1 threads=5
|
|
|
|
WSGIScriptAlias / /path/to/zerobin/app.wsgi
|
|
|
|
|
|
|
|
<Directory /path/to/zerobin/zerobin/>
|
|
|
|
WSGIProcessGroup zerobin
|
|
|
|
WSGIApplicationGroup %{GLOBAL}
|
|
|
|
Order deny,allow
|
|
|
|
Allow from all
|
|
|
|
</Directory>
|
|
|
|
</VirtualHost></pre>
|
|
|
|
</div>
|
|
|
|
<p>Activate the website (as admin):</p>
|
|
|
|
<div class="highlight-python"><pre>a2ensite zerobin</pre>
|
|
|
|
</div>
|
|
|
|
<p>And reload the apache configuration (as admin):</p>
|
|
|
|
<div class="highlight-python"><pre>service apache2 reload</pre>
|
|
|
|
</div>
|
|
|
|
<p>You’ll note that we refer to a file named app.wsgi. It’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">'/path/to/zerobin/parent/dir'</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">'/path/to/settings.py'</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’t have time to cover
|
|
|
|
it yet. Please contact us if you ever get the need to use it.</p>
|
2012-05-18 16:29:52 +04:00
|
|
|
</div>
|
2012-05-07 17:08:58 +04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="sphinxsidebar">
|
|
|
|
<div class="sphinxsidebarwrapper">
|
2012-05-18 16:29:52 +04:00
|
|
|
<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>
|
2012-05-19 00:18:40 +04:00
|
|
|
<li><a class="reference internal" href="#cgi">CGI</a></li>
|
2012-05-18 16:29:52 +04:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2012-05-07 17:08:58 +04:00
|
|
|
<h4>Previous topic</h4>
|
|
|
|
<p class="topless"><a href="easy_install.html"
|
2012-05-18 16:29:52 +04:00
|
|
|
title="previous chapter">Easiest installation</a></p>
|
2012-05-07 17:08:58 +04:00
|
|
|
<h4>Next topic</h4>
|
|
|
|
<p class="topless"><a href="nginx_install.html"
|
2012-05-18 16:29:52 +04:00
|
|
|
title="next chapter">Nginx setup</a></p>
|
2012-05-07 17:08:58 +04:00
|
|
|
<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 id="searchbox" style="display: none">
|
|
|
|
<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">
|
|
|
|
<h3>Navigation</h3>
|
|
|
|
<ul>
|
|
|
|
<li class="right" style="margin-right: 10px">
|
|
|
|
<a href="../genindex.html" title="General Index"
|
|
|
|
>index</a></li>
|
|
|
|
<li class="right" >
|
2012-05-18 16:29:52 +04:00
|
|
|
<a href="nginx_install.html" title="Nginx setup"
|
2012-05-07 17:08:58 +04:00
|
|
|
>next</a> |</li>
|
|
|
|
<li class="right" >
|
2012-05-18 16:29:52 +04:00
|
|
|
<a href="easy_install.html" title="Easiest installation"
|
2012-05-07 17:08:58 +04:00
|
|
|
>previous</a> |</li>
|
|
|
|
<li><a href="../index.html">0bin 0.1 documentation</a> »</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="footer">
|
|
|
|
© Copyright 2012, Sam et Max.
|
|
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|