This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinstall.txt
162 lines (129 loc) · 6.07 KB
/
install.txt
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# You will need to install git, mysql, sass, pleeease, and everything in requirements.txt.
# virtualenv is also highly recommended.
# This includes lxml, which requires gcc, g++, and development packages for quite a few libraries.
# You will eventually also need mysqlclient for python, and hence libmysqlclient.
# To install everything you will need, run these commands on a debian system.
$ sudo apt install git gcc g++ make python-dev libxml2-dev libxslt1-dev zlib1g-dev ruby-sass gettext curl
$ wget -q --no-check-certificate -O- https://bootstrap.pypa.io/get-pip.py | sudo python
$ sudo pip install virtualenv
$ wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
# For this you should select the latest version.
...
$ wget -O- https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt install mysql-server libmysqlclient-dev nodejs
...
# You will be asked to enter the root password for MySQL.
# It's a good idea to remember it!
...
$ sudo npm install -g pleeease-cli
# Database setup.
$ mysql -uroot -p
# Enter root password to login.
# Run these commands to create the database.
mysql> CREATE DATABASE dmoj DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
mysql> GRANT ALL PRIVILEGES ON dmoj.* to 'dmoj'@'localhost' IDENTIFIED BY '<password>';
mysql> exit
# Now that you are done, you can think about actually installing the site.
# First create virtualenv and activate it.
$ virtualenv dmojsite
$ . dmojsite/bin/activate
# Now fetch the site source code.
(dmojsite) $ git clone https://github.com/DMOJ/site.git
(dmojsite) $ cd site
(dmojsite) $ git submodule init
(dmojsite) $ git submodule update
# Henceforth, (dmojsite) commands assumes you are in the code
# directory, with virtualenv active.
# Install python dependencies into virtualenv.
(dmojsite) $ pip install -r requirements.txt
(dmojsite) $ pip install mysqlclient
# You will now need to configure dmoj/local_settings.py
# You should make a copy from dmoj/local_settings.example.py
# and read through it, making changes as necessary.
# Most importantly, you want to update MySQL credentials.
# Note: leave debug mode on for now.
# Now you should probably verify that everything is going according to plan.
(dmojsite) $ python manage.py check
# Setup database tables.
(dmojsite) $ python manage.py migrate
# DMOJ uses sass and pleeease to generate style.css
# You will need to run this shell script to get this done.
(dmojsite) $ ./make_style.sh
# Now collect static files into STATIC_ROOT as specified in local_settings.
(dmojsite) $ python manage.py collectstatic
# You need to generate i18n files.
(dmojsite) $ python manage.py compilemessages
(dmojsite) $ python manage.py compilejsi18n
# Now load some initial data, so your install is not blank.
(dmojsite) $ python manage.py loaddata navbar
(dmojsite) $ python manage.py loaddata language_small
# You should create an admin account.
(dmojsite) $ python manage.py createsuperuser
# At this point, you should attempt to runserver and see if it all works.
(dmojsite) $ python manage.py runserver 0.0.0.0:8000
# You should Ctrl-C to exit after verifying.
# You should also test to see if bridged runs.
(dmojsite) $ python manage.py runbridged
# If there are no errors after about 10 seconds, it probably works.
# You should Ctrl-C to exit.
# Your job is half done.
# You should now switch to a real python application server.
# The rest of this guide assumes you are using uwsgi and nginx to serve the site.
# It also assumes that you will be using supervisord to manage site and bridged.
# There be dragons should you use something else.
# Now, copy uwsgi-template.ini to uwsgi.ini and edit it.
# You should at least change the paths to reflect your install.
# You need to install uwsgi. The easiest way:
(dmojsite) $ curl http://uwsgi.it/install | bash -s default $PWD/uwsgi
# To test:
(dmojsite) $ ./uwsgi --ini uwsgi.ini
# If it says workers are spawned, it probably works.
# You should Ctrl-C to exit.
# If it all works out, you should now install supervisord and configure it.
$ sudo apt install supervisor
# Copy our site.conf to /etc/supervisor/conf.d/site.conf, and fill in the fields.
# Copy our bridged.conf to /etc/supervisor/conf.d/bridged.conf, and fill in the fields.
# Reload supervisor configuration.
$ sudo supervisorctl update
# Wait a few seconds, and run:
$ sudo supervisorctl status
# If both processes are running, everything is good!
# Otherwise peek at the logs and see what's wrong.
# Now it's time to set up nginx.
$ sudo apt install nginx
# Typically, nginx site files are located in /etc/nginx/conf.d.
# Some installations might place it at /etc/nginx/sites-available
# and require a symlink in /etc/nginx/sites-enabled.
# You should copy the sample nginx.conf, edit it and place it in whereever
# it is supposed to be.
# Now reload the nginx configuration.
$ sudo service nginx reload
# You should be good to go. Visit the site at where you set it up.
# If it doesn't, check nginx logs and uwsgi log stdout/stderr.
# Now, remember to set DEBUG to False in local_settings.
## Configuration of event server.
# Create config.js. This assumes you use nginx, or there be dragons.
# You may need to shuffle ports if they are already used.
(dmojsite) $ cat > websocket/config.js
module.exports = {
get_host: '127.0.0.1',
get_port: 15100,
post_host: '127.0.0.1',
post_port: 15101,
http_host: '127.0.0.1',
http_port: 15102,
long_poll_timeout: 29000,
};
# get_port should be the same as the port for /event/ in nginx.conf
# http_port should be the same as the port for /channels/ in nginx.conf
# post_port should be the same as the port in EVENT_DAEMON_POST in local_settings.
# You need to configure EVENT_DAEMON_GET and EVENT_DAEMON_POLL.
# You need to uncomment the relavent section in the nginx configuration.
# Need to install the dependencies.
(dmojsite) $ npm install qu ws simplesets
(dmojsite) $ pip install websocket-client
# Now copy wsevent.conf to /etc/supervisor/conf/wsevent.conf, changing paths.
# and then update supervisor.
$ sudo supervisorctl update
# Now do remember to reload nginx, restart bridge and site.