README.md 3.05 KB
Newer Older
1

Okhin's avatar
Okhin committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Net Neutrality MONitor

This django application is used to collect data about net neutrality violation,
to allow a name and shame policy.

# Setup

You have to clone this branch (django-1.8) to get the latest source code.
The recommended way is to use a virtualenv and to run the app through apache and
uwsgi.

## System dependencies

You need to install some development package to activate al the needed python
modules.

    sudo apt-get install libxml2-dev libxslt-dev build-essential python-dev libsqlite3-dev libjpeg-dev zlib1g-dev libapache2-mod-uwsgi libapache2-mod-wsgi uwsgi-plugin-python libfreetype6-dev uwsgi

## Create a virtualenv

The recommended way is to install a python-virtualenv and to run the django
application from there.

    virtualenv nnmon-env
    source nnmon-env/bin/activate

## Get the source

You need to git clone the repository:

Okhin's avatar
Okhin committed
32
    git clone http:/git.laquadrature.net/la-quadrature-du-net/respect-my-net.git respect-my-net
Okhin's avatar
Okhin committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
111

## Install the module dependencies

Now, you need to install all the needed python modules, with pip.

    pip install --upgrade -r nnmon-requirements.txt

## Configure django

Edit the configuration file for django. Pay special attention to DEBUG, various
path and SECRET_KEY settings. Next you need to setup the database, using the
manage.py tool.

    python manage.py migrate

## Set-up uwsgi

You need to create an application for uwsgi. Create a file in
/etc/uwsgi/apps-available with the fllowing content. Adapat to your needs and
read the documentation:

    [uwsgi]
    plugins = python
    uid = www-data

    pythonpath = /home/rmn/respect-my-net
    module = nnmon.wsgi:application
    env = DJANGO_SETTINGS_MODULE=nnmon.settings
    chdir = /home/rmn/respect-my-net
    home = /home/rmn/nnmon-env

    vacuum = True
    master = True
    max-requests = 5000
    pidfile = /run/uwsgi/app/rmn/pid
    daemonize = /var/log/uwsgi/rmn.log
    socket = /run/uwsgi/app/rmn/socket

PythonPath is where the django app is based (ie: the root of the git
repository), chdir is the same path. Home, is the path of the virtualenv created
above.

Now you need to activate the apps by creating a symoblic link into
/etc/uwsgi/apps-enabled, and to restart uwsgi.

    cd /etc/uwsgi/apps-enabled
    ln -s ../apps-available/nnmond.conf
    service restart uwsgi

## Set-up apache

You need to setup apache (or nginx depending on what you prefer). First, you
need to actvivate the uwsgi module:

    a2enmod uwsgi
    service apache2 restart

And now you need to create a VirtualHost in
/etc/apache2/sites-availabe/nnmon.conf

    <virtualhost *:80>
        ServerName rmn.example.com

        SetHandler uwsgi-handler
        uWSGISocket /run/uwsgi/app/rmn/socket

        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T
    %{Host}i" alternc
        CustomLog /var/log/apache2/access.log alternc
        ErrorLog /var/log/apache2/rmn.error.log
    </virtualhost>

You need to activate the website and the to reload apache. Of course, for
production use, you should use a TLS VirtualHost.

    a2ensite nnmon
    service apache2 reload