-
Notifications
You must be signed in to change notification settings - Fork 6
/
INSTALL
89 lines (66 loc) · 3.83 KB
/
INSTALL
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
Installation of required software (for Ubuntu and Mac OS):
* sudo aptitude install python python-setuptools git libmysqlclient-dev python-lxml
* sudo easy_install pip
* git clone git://github.com/sergkop/elections_network.git CODE_DIR
* sudo pip install -r CODE_DIR/requirements.txt
Installation (for Windows):
* setup Python 2.7, git
* install setuptools and pip (http://pypi.python.org/pypi/pip)
* git clone git://github.com/sergkop/elections_network.git CODE_DIR
* pip install -r CODE_DIR/requirements.txt
Running development server:
* rename site_settings.py.example to site_settings.py and set proper settings values
* python manage.py syncdb (agree to create superuser)
* python manage.py migrate
* python manage.py init_locations
* 'python manage.py runserver' to run server
* project is accessible at http://127.0.0.1:8000, admin interface - http://127.0.0.1:8000/admin/
Common problems (Linux/Mac OS):
* Django admin media files are not loaded - make sure /static/admin/* url points to .../django/contrib/admin/media/ folder
in django code directory
Common problems (Windows):
* If syncdb step fails with the error in Windows 7
django.db.utils.DatabaseError: You must not use 8-bit bytestrings unless you use
a text_factory that can interpret 8-bit bytestrings (like text_factory = str).
It is highly recommended that you instead just switch your application to Unicode strings.
it is caused by the presence of non-latin symbols in the name of windows user. This is a known
problem with Python2.7 and the only known workaround is to user another account with English letters-only usernames.
* When you login into admin interface (http://127.0.0.1:8000/admin/) it can happen, that
media files haven't loaded (interface looks ugly). Try accessing http://127.0.0.1:8000/static/css/screen/content.css),
if it shows an error
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
In this case you need to run regedit, find "HKEY_CLASSES_ROOT\MIME\Database\Content Type" entry
and remove all MIMETYPES with non-latin symbols in the name (it must be only "аудио/..." and "видео/...")
General advice:
* Database is stored in database.sqlite, which you can always delete it and re-run
'python manage.py syncdb', 'python manage.py init_db' if something goes wrong.
Testing:
* Run 'python manage.py init_test_data' to load database with users, links and contacts created for test purposes
Build a graph of database structure (requires graphviz and pygraphviz):
* python manage.py graph_models -g grakon links locations navigation organizations registration reports users loginza auth -o docs/db_structure.png
-------- Optionally create virtualenv -------
* sudo pip install virtualenv
* virtualenv --no-site-packages VIRTUAL_ENV_DIR
* 'source VIRTUAL_ENV_DIR/bin/activate' (if installed must be run every time before running django server or set VIRTUALENV in site_settings.py)
Deployment:
* install postfix (smtp client)
* install memcached
* Configure vkontakte comments, remove {autoPublish: 0} option of vkontakte comments in templates/location.html in production
* configure yandex.metrika
* configure Google Analytics
* set debug=False in site_settings.py on production
* configure django logging
Init server:
useradd -d /home/serg --shell /bin/bash -m serg
aptitude install mc nginx memcached postfix
add 'serg ALL=(ALL) ALL' to /etc/sudoers
create /home/serg/.ssh/authorized_keys
copy id_rsa and id_rsa.pub to /home/serg/.ssh
Restarting the server:
./server.sh
/etc/init.d/memcached restart
/etc/init.d/postfix restart
/etc/init.d/nginx restart
Firewall:
sudo ufw disable
sudo ufw enable