summaryrefslogtreecommitdiff
path: root/INSTALL
blob: f34b43f68c859b00b154407d34d723f9593cd32d (plain)
1
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
32
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
================== HOW RUN THE PYTHON BANK =====================

----------------------------0 Preface --------------------------

In order to get the whole bank's codebase, a submodule needs to be
pulled; so from the bank's top directory, run

$ git submodule update --init

(this submodule carries some HTML/JS code which is reused among all
Taler's Web components)

As for the database backend, the bank uses PostgreSQL and needs a
database called 'talertest' in it, owned by the user which launches
the bank

---------------------1 The Pythonic way ------------------------

Make sure your system has 'virtualenv' and 'pip' installed.
For example, on Debian systems, run:

# apt-get install virtualenv python3-pip python3.4-dev

Next, create an environment which will "host" the bank's dependencies:

$ virtualenv bank_env

This should create a directory named 'bank_env/' in your current
working directory.
That directory will contain all the Pythonic dependencies of the bank.

To activate your environment in the current shell, use:

$ source bank_env/bin/activate

(To later deactivate it, you can simply close the shell.)
Inside the "activated" shell, install the dependencies:

$ pip install -r requirements.txt

The file 'requirements.txt' is contained in this folder.

Once the environment is set up, the bank can be launched. For that
purpose, you need to first

$ cd django/

Before actually launching the bank, the bank's database and static files'
serving must be initialized. Give the following commands (respecting the
sequence):

$ python manage.py makemigrations
$ python manage.py migrate $ python manage.py collectstatic --noinput

The following command is also needed, in order to create some predefined
accounts:

$ python manage.py pre_accounts

In order to add sample donations to predefined account:

$ python manage.py sample_donations

If everything has worked fine, launch the bank's web server with:

$ python manage.py runserver 127.0.0.1:8080

The bank's homepage is now available at http://127.0.0.1:8080

--------------------- 2 The GNU way ----------------------------

NOTE

(*) the '--prefix' option will point a directory which hosts both the
virtualenv data and the bank's website itself

(*) the '--exec-prefix' option will point to a directory which will host
the final "executable" (i.e. a shell script which launches the wsgi service),
so it should be somewhere known by PATH

(*) 'make install' performs both sources deployment _and_ database initialization;
the latter needs to be done with the same user who runs the bank application. So if
'make install' is done as 'root' user, make sure 'root' has the mean to modify the
'talertest' database. Otherwise, just point '--prefix' and '--exec-prefix' to a location
accessible to the user who will run the bank

The installation is done by the usual

$ ./bootstrap.sh
$ ./configure # consider to tune at least '--prefix'
$ make
$ make install

Though not strictly needed, the following step populates the database with
sample data

$ make populatedb

If the previous steps were successful, then the bank should be run with

$ taler-bank-wsgi

Please note that the bank works properly only via nginx since it uses
SSI includes.

To quickly run the bank without nginx, do

$ source PFX/venv/bin/activate
$ cd PFX/src
$ python manage.py runserver 127.0.0.1:8000

To populate the database without relying on Makefile, do

$ source PFX/venv/bin/activate
$ cd PFX/src
$ python manage.py pre_accounts
$ python manage.py sample_data


----------------- 3 How to bind Django and nginx ---------------

The basic statements needed to run the bank via nginx are shown in
'django_nginx.conf'. Once those statements have been applied, assuming
your CWD is still 'django/', the bank is run with

$ ./django_wsgi.sh /path/to/bank_env

The nginx configuration is based on the guide in [1]
[1] http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html