1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
0bin/docs/.build/html/en/nginx_install.html

215 lines
8.4 KiB
HTML
Raw Normal View History

<!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>Nginx setup &mdash; 0bin 0.1 documentation</title>
2015-05-10 20:53:55 +03:00
<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="Using supervisor" href="using_supervisor.html" />
<link rel="prev" title="Apache setup" href="apache_install.html" />
</head>
2015-05-10 20:53:55 +03:00
<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="using_supervisor.html" title="Using supervisor"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="apache_install.html" title="Apache setup"
accesskey="P">previous</a> |</li>
2015-05-10 20:53:55 +03:00
<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">
2015-05-10 20:53:55 +03:00
<div class="body" role="main">
<div class="section" id="nginx-setup">
<h1>Nginx setup<a class="headerlink" href="#nginx-setup" title="Permalink to this headline"></a></h1>
2012-05-19 00:58:14 +04:00
<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>Nginx is a very popular choice to serve a Python project:</p>
<ul class="simple">
<li>It&#8217;s fast.</li>
<li>It&#8217;s lightweight.</li>
<li>Configuration files are simple.</li>
</ul>
2012-05-19 00:47:17 +04:00
<dl class="docutils">
<dt>If you have your own server, it&#8217;s the best choice. If not, try the</dt>
<dd><a class="reference internal" href="easy_install.html"><em>easiest setup</em></a>, or the <a class="reference internal" href="apache_install.html"><em>Apache</em></a> setup.</dd>
</dl>
<p>Nginx doesn&#8217;t run any Python process, it only serve requests from outside to
the Python server.</p>
<p>Therefor there are two steps:</p>
<ul class="simple">
<li>Run the Python process.</li>
<li>Run Nginx.</li>
</ul>
<p>You will benefit from having:</p>
<ul class="simple">
2013-04-23 01:22:33 +04:00
<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 &#8211;user doesn&#8217;t
work on your OS;</li>
<li>the ability to manage a Python process without touching Nginx or the other
processes. It&#8217;s very handy for updates.</li>
</ul>
<div class="section" id="the-python-process">
<h2>The Python process<a class="headerlink" href="#the-python-process" title="Permalink to this headline"></a></h2>
<p>Run 0bin as usual, but this time make it listen to a local port and host. E.G:</p>
2015-05-10 20:53:55 +03:00
<div class="highlight-python"><div class="highlight"><pre>zerobin --host 127.0.0.1 --port 8000
</pre></div>
</div>
2013-04-23 01:22:33 +04:00
<p>In PHP, when you edit a file, the changes are immediately visible. In Python,
the whole code is often loaded in memory for performance reasons. This means
you have to restart the Python process to see the changes effect. Having a
separate process let you do this without having to restart the server.</p>
</div>
<div class="section" id="nginx">
<h2>Nginx<a class="headerlink" href="#nginx" title="Permalink to this headline"></a></h2>
<p>Nginx can be installed with you usual package manager, so we won&#8217;t cover
installing it.</p>
<p>Vous must create a Nginx configuration file for 0bin. On GNU/Linux, they usually
go into /etc/nginx/conf.d/. Name it zerobin.conf.</p>
<p>The minimal configuration file to run the site is:</p>
2015-05-10 20:53:55 +03:00
<div class="highlight-python"><div class="highlight"><pre>server {
listen 80;
server_name www.yourwebsite.com;
location / {
proxy_pass http://127.0.0.1:8000;
}
2015-05-10 20:53:55 +03:00
}
</pre></div>
</div>
<p><cite>proxy_pass</cite> just passes the external request to the Python process.
The port much match the one used by the 0bin process of course.</p>
<p>You can make some adjustements to get a better user experience:</p>
2015-05-10 20:53:55 +03:00
<div class="highlight-python"><div class="highlight"><pre>server {
listen 80;
server_name www.yourwebsite.com;
location /favicon.ico {
root /path/to/zerobin/static/img;
}
location /static/ {
root /path/to/zerobin;
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
# Disable gzip for certain browsers.
gzip_disable ~@~\MSIE [1-6].(?!.*SV1)~@~];
expires modified +90d;
}
location / {
proxy_pass http://zerobin_cherrypy;
}
2015-05-10 20:53:55 +03:00
}
</pre></div>
</div>
<p>This make Nginx serve the favicon and static files, set the expire HTTP headers
and make sure gzip compression is used with browsers that support it.</p>
</div>
</div>
</div>
</div>
</div>
2015-05-10 20:53:55 +03:00
<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="#">Nginx setup</a><ul>
<li><a class="reference internal" href="#the-python-process">The Python process</a></li>
<li><a class="reference internal" href="#nginx">Nginx</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="apache_install.html"
title="previous chapter">Apache setup</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="using_supervisor.html"
title="next chapter">Using supervisor</a></p>
2015-05-10 20:53:55 +03:00
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/en/nginx_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>
2015-05-10 20:53:55 +03:00
<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="using_supervisor.html" title="Using supervisor"
>next</a> |</li>
<li class="right" >
<a href="apache_install.html" title="Apache setup"
>previous</a> |</li>
2015-05-10 20:53:55 +03:00
<li class="nav-item nav-item-0"><a href="../index.html">0bin 0.1 documentation</a> &raquo;</li>
</ul>
</div>
2015-05-10 20:53:55 +03:00
<div class="footer" role="contentinfo">
&copy; Copyright 2012, Sam et Max.
2015-05-10 20:53:55 +03:00
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.1.
</div>
</body>
</html>