Skip to content

Commit a3dcbe9

Browse files
committed
Documentation is now exhaustive and zerobin is apache friendly
1 parent 97935e5 commit a3dcbe9

40 files changed

+1104
-153
lines changed
5.8 KB
Binary file not shown.
3.12 KB
Binary file not shown.
-731 Bytes
Binary file not shown.
14 Bytes
Binary file not shown.
6.56 KB
Binary file not shown.
237 Bytes
Binary file not shown.
Binary file not shown.
3.29 KB
Binary file not shown.
Binary file not shown.

docs/.build/doctrees/index.doctree

-2.01 KB
Binary file not shown.

docs/.build/html/_sources/en/apache_install.txt

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
Apache setup
33
=============
44

5-
Apache is slower, heavier and more complicated to setup than Nginx. But it's also
6-
much more famous:
5+
Apache is heavier than Nginx. But it's also much more famous:
76

87
- more people will be able to help you on forums;
98
- your hosting will most probably support Apache;
@@ -33,7 +32,65 @@ the setup of the Apache module mod_wsgi. If you don't know how to do this, or
3332
if you can't do it (E.G: your hosting won't let you), you need to go for
3433
the CGI setup.
3534

36-
==========
35+
First, make sure you have mod_wsgi installed and enable by running (as admin)::
36+
37+
a2enmod wsgi
38+
39+
This enable mod_wsgi. It it doesn't, install it first (on ubuntu, the package
40+
is libapache2-mod-wsgi).
41+
42+
Then create an Apache configuration file, usually in /etc/apache/sites-available/.
43+
Name it zerobin::
44+
45+
<VirtualHost *:80>
46+
ServerName www.yourwebsite.com
47+
48+
WSGIDaemonProcess zerobin user=www-data group=www-data processes=1 threads=5
49+
WSGIScriptAlias / /path/to/zerobin/app.wsgi
50+
51+
<Directory /path/to/zerobin/zerobin/>
52+
WSGIProcessGroup zerobin
53+
WSGIApplicationGroup %{GLOBAL}
54+
Order deny,allow
55+
Allow from all
56+
</Directory>
57+
</VirtualHost>
58+
59+
Activate the website (as admin)::
60+
61+
a2ensite zerobin
62+
63+
And reload the apache configuration (as admin)::
64+
65+
service apache2 reload
66+
67+
You'll note that we refer to a file named app.wsgi. It's a Python file
68+
creating the application Apache is going to use to start the Python process::
69+
70+
import os, sys
71+
72+
# make sure the zerobin module is in the PYTHON PATH and importable
73+
ZEROBIN_PARENT_DIR = os.path.dirname(os.path.dirname(__file__))
74+
sys.path.insert(0, ZEROBIN_PARENT_DIR)
75+
76+
# create the wsgi callable
77+
from zerobin.routes import get_app
78+
settings, application = get_app(compressed_static=True)
79+
80+
You can of course create your own, as the `get_app` function is the only
81+
way to pass settings to 0bin with this setup. You would do this by creating
82+
a configuration file and passing it to the function::
83+
84+
import os, sys
85+
86+
ZEROBIN_PARENT_DIR = '/path/to/zerobin/parent/dir'
87+
sys.path.insert(0, ZEROBIN_PARENT_DIR)
88+
89+
from zerobin.routes import get_app
90+
settings, application = get_app(settings_file='/path/to/settings.py')
91+
92+
CGI
93+
===
3794

38-
This setup is considered as slow, but you will still benefit from Apache
39-
robustness.
95+
You can also run 0bin using CGI, but infortunaly we didn't have time to cover
96+
it yet. Please contact us if you ever get the need to use it.

docs/.build/html/_sources/en/nginx_install.txt

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,51 @@ installing it.
5151
Vous must create a Nginx configuration file for 0bin. On GNU/Linux, they usually
5252
go into /etc/nginx/conf.d/. Name it zerobin.conf.
5353

54-
The minimal file to run the site is:
55-
56-
But you can make some adjustement to get better perfomances:
54+
The minimal configuration file to run the site is::
55+
56+
server {
57+
listen 80;
58+
server_name www.yourwebsite.com;
59+
60+
location / {
61+
proxy_pass http://127.0.0.1:8000;
62+
}
63+
}
64+
65+
`proxy_pass` just passes the external request to the Python process.
66+
The port much match the one used by the 0bin process of course.
67+
68+
You can make some adjustements to get a better user experience::
69+
70+
server {
71+
listen 80;
72+
server_name www.yourwebsite.com;
73+
74+
location /favicon.ico {
75+
root /path/to/zerobin/static/img;
76+
}
77+
78+
location /static/ {
79+
root /path/to/zerobin;
80+
gzip on;
81+
gzip_http_version 1.0;
82+
gzip_vary on;
83+
gzip_comp_level 6;
84+
gzip_proxied any;
85+
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
86+
gzip_buffers 16 8k;
87+
# Disable gzip for certain browsers.
88+
gzip_disable ~@~\MSIE [1-6].(?!.*SV1)~@~];
89+
expires modified +90d;
90+
}
91+
92+
location / {
93+
proxy_pass http://zerobin_cherrypy;
94+
}
95+
}
96+
97+
This make Nginx serve the favicon and static files, set the expire HTTP headers
98+
and make sure gzip compression is used with browsers that support it.
5799

58100

59101

docs/.build/html/_sources/en/options.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
2-
3-
--host=STR
4-
5-
The host on which to listen for incomming request. Usually 127.0.0.1 to
6-
listen locally or 0.0.0.0 to listen from the outside.
7-
8-
Default: 127.0.0.1
9-
Setting file : HOST
10-
11-
12-
131
============
142
Options
153
============

docs/.build/html/_sources/en/theming.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Theming
33
=======
44

5-
0bin comes a complete theming support, but for now it's not well ingrated.
5+
0bin comes with a complete theming support, but for now it's not well integrated.
66

7-
If you wish to create your own theme, you'll need to create template similar
7+
If you wish to create your own theme, you'll need to create templates similar
88
to the ones in zerobin/view, and add the path to the director containing them
99
to the settings file.
1010

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
1-
====================
1+
=================
22
Using supervisor
3-
====================
3+
=================
4+
5+
Supervisor is a very nice way to manage you Python processes. We won't cover
6+
the setup (which is just apt-get install supervisor or pip install supervisor
7+
most of the time), but here is a quick overview on how to use it.
8+
9+
Create a configuration file named supervisor.ini::
10+
11+
[unix_http_server]
12+
file=/tmp/supervisor.sock;
13+
14+
[supervisorctl]
15+
serverurl=unix:///tmp/supervisor.sock;
16+
17+
[rpcinterface:supervisor]
18+
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
19+
20+
[supervisord]
21+
logfile=/tmp/zerobin.log
22+
logfile_maxbytes=50MB
23+
logfile_backups=2
24+
loglevel=trace
25+
pidfile=/tmp/supervisord.pid
26+
nodaemon=false
27+
minfds=1024
28+
minprocs=200
29+
user=zerobin
30+
31+
[program:zerobin]
32+
command=/path/to/zerobin/zerobin.py --port 80 --compressed-static
33+
directory=/path/to/zerobin/
34+
environment=PYTHONPATH='/path/to/zerobin/'
35+
user=zerobin
36+
autostart=true
37+
autorestart=true
38+
39+
The 4 first entries are just boiler plate to get you started, you can copy
40+
them verbatim.
41+
42+
The last one define one (you can have many) process supervisor should manage.
43+
44+
It means it will run the command::
45+
46+
/path/to/zerobin/zerobin.py --port 80 --compressed-static
47+
48+
In the directory, with the environnement and the user you defined.
49+
50+
This command will be ran as a daemon, in the background.
51+
52+
`autostart` and `autorestart` just make it fire and forget: the site will always be
53+
running, even it crashes temporarly or if you retart the machine.
54+
55+
The first time you run supervisor, pass it the configuration file::
56+
57+
supervisord -c /path/to/supervisor.ini
58+
59+
Then you can manage the process by running::
60+
61+
supervisorctl -c /path/to/supervisor.ini
62+
63+
It will start a shell from were you can start/stop/restart the service
64+
65+
You can read all errors that might occurs from /tmp/zerobin.log.
66+
67+
.. Note::
68+
69+
If you installed zerobin in a virtualenv, you may set the command
70+
to run directly from it::
71+
72+
command=/path/to/virtualenv/bin/zerobin --port 80 --compressed-static

docs/.build/html/_sources/fr/apache_install.txt

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
Installation avec Apache
33
=========================
44

5-
Apache est plus lent, plus lourd, et plus complexe à mettre en oeuvre que Nginx.
6-
Mais il est aussi beaucoup plus connu:
5+
Apache est plus lourd que Nginx mais il est aussi beaucoup plus connu:
76

87
- plus de gens pourront vous aider les fora;
98
- votre hébergeur propose surement Apache;
@@ -34,9 +33,67 @@ l'installation du modle Apache mod_wsgi. Si vous ne savez pas comment faire,
3433
ou si vous ne pouvez pas le faire (par exemple sur un hébergement mutualisé
3534
qui ne le propose pas), il vous faudra choisir l'installation CGI.
3635

36+
Premièrement, assurez-vous d'avoir mod_wsgi installé et chargé (en tant qu'admin)::
3737

38-
Mod_CGI
39-
==========
38+
a2enmod wsgi
39+
40+
Ceci va activer mod_wsgi. Si cela ne marche pas, il faudra l'installer d'abord (
41+
sur ubuntu, le paquet est libapache2-mod-wsgi)
42+
43+
Ensuite, il faut créer un fichier de configuration Apache, généralement dans
44+
/etc/apache/sites-available/. Nommez le zerobin::
45+
46+
<VirtualHost *:80>
47+
ServerName www.votersiteweb.com
48+
49+
WSGIDaemonProcess zerobin user=www-data group=www-data processes=1 threads=5
50+
WSGIScriptAlias / /chemin/vers/zerobin/app.wsgi
51+
52+
<Directory /chemin/vers/zerobin/>
53+
WSGIProcessGroup zerobin
54+
WSGIApplicationGroup %{GLOBAL}
55+
Order deny,allow
56+
Allow from all
57+
</Directory>
58+
</VirtualHost>
59+
60+
Activez le site web (en tant qu'admin)::
61+
62+
a2ensite zerobin
63+
64+
Et rechargez la configuration d'Apache (en tant qu'admin)::
65+
66+
service apache2 reload
67+
68+
Vous aurez noté que l'on fait référence à un fichier nommé app.wsgi. C'est un
69+
fichier Python qui créé l'application qu'Apache va utiliser pour lancer le
70+
processus Python::
71+
72+
import os, sys
73+
74+
# s'assurer que le module zerobin est dans le PYTHON PATH et importable
75+
ZEROBIN_PARENT_DIR = os.path.dirname(os.path.dirname(__file__))
76+
sys.path.insert(0, ZEROBIN_PARENT_DIR)
77+
78+
# créer le wsgi callable
79+
from zerobin.routes import get_app
80+
settings, application = get_app(compressed_static=True)
81+
82+
Vous pouvez bien sûr créer le votre, puisque la fonction `get_app` et le seul
83+
moyen de passer des paramètres à 0bin avec cette installation. Cela peut se
84+
faire en créant un fichier de configuration et en le passant à la fonction::
85+
86+
import os, sys
87+
88+
ZEROBIN_PARENT_DIR = '/chemin/du/dossier/parent/de/zerobin'
89+
sys.path.insert(0, ZEROBIN_PARENT_DIR)
90+
91+
from zerobin.routes import get_app
92+
settings, application = get_app(settings_file='/path/to/settings.py')
93+
94+
CGI
95+
===
96+
97+
Vous pouvez aussi utiliser CGI, mais nous n'avons pas encore eu le temps de
98+
couvrir cette partie. Contactez nous si vous avez besoin de l'utiliser.
4099

41-
Cette installation est considérée comme relativement lente. Mais vous bénéficierez
42-
tout de même de la robustesse d'Apache

docs/.build/html/_sources/fr/nginx_install.txt

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,53 @@ nous ne couvrirons pas cette partie.
5555
Vous devez créer une fichier de configuration Nginx pour 0bin. Sous GNU/Linux,
5656
on les mets en général dans /etc/nginx/conf.d/. Nommez le zerobin.conf.
5757

58-
Le fichier minimal pour faire tourner le site est:
59-
60-
Mais on peut apporter plusieurs améliorations de performance:
61-
58+
Le fichier de configuration minimal pour faire tourner le site est::
59+
60+
server {
61+
listen 80;
62+
server_name www.votresiteweb.com;
63+
64+
location / {
65+
proxy_pass http://127.0.0.1:8000;
66+
}
67+
}
68+
69+
`proxy_pass` transmet les requêtes aux processus Python. Bien entendu le
70+
port doit correspondre à celui utilisé par 0bin.
71+
72+
On peut apporter plusieurs améliorations à l'expérience utilisateur::
73+
74+
server {
75+
listen 80;
76+
server_name www.votresiteweb.com;
77+
78+
location /favicon.ico {
79+
root /chemin/vers/zerobin/static/img;
80+
}
81+
82+
location /static/ {
83+
root /chemin/vers/zerobin;
84+
gzip on;
85+
gzip_http_version 1.0;
86+
gzip_vary on;
87+
gzip_comp_level 6;
88+
gzip_proxied any;
89+
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
90+
gzip_buffers 16 8k;
91+
# Disable gzip for certain browsers.
92+
gzip_disable ~@~\MSIE [1-6].(?!.*SV1)~@~];
93+
expires modified +90d;
94+
}
95+
96+
location / {
97+
proxy_pass http://zerobin_cherrypy;
98+
}
99+
}
100+
101+
Nginx sert maintenant le favicon ainsi que les fichiers statiques,
102+
on a ajouté une date d'expiration dans les en-têtes HTTP
103+
et on s'assure que la compression gzip est utilisée pour les navigateurs
104+
qui la supporte.
62105

63106

64107

0 commit comments

Comments
 (0)