-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebian-8-installation.html
517 lines (411 loc) · 17.3 KB
/
debian-8-installation.html
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
pre { border: 1px solid #aaa; padding: 5px; background: #deeff5; width: 99%}
</style>
</head>
<body>
<h1 id="installing-mailman-3-under-debian-8">Installing Mailman 3 under Debian 8</h1>
<p>May 2017.</p>
<p>We’ll use Vagrant:</p>
<pre><code>$ cat Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "debian/jessie64"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048" # Ran into some trouble with only 1GB of RAM
end
end
$ vagrant up
$ vagrant ssh
</code></pre>
<p>Everything following is in the VM.</p>
<pre><code>$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.7 (jessie)
Release: 8.7
Codename: jessie
</code></pre>
<p>Let’s go install some packages:</p>
<pre><code>$ sudo apt-get install python-pip python3-pip python-dev sqlite3 libsqlite3-dev postfix ruby-sass vim git curl nginx postgresql-client postgresql postgresql-contrib libpq-dev
</code></pre>
<p>For postfix installation need to choose the “General type of mail configuration.” Went for option “Internet Site,” and host name mail.vanlu.ga.</p>
<p>One more package</p>
<pre><code>$ sudo pip install virtualenv
</code></pre>
<p>By the way, these are our python versions.</p>
<pre><code>$ pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)
$ python2 --version
Python 2.7.9
$ python3 --version
Python 3.4.2
</code></pre>
<p>Now add a user for the various Mailman 3 packages.</p>
<pre><code>$ sudo adduser mm3 # enter password etc.
$ su mm3
$ cd
$ pwd
/home/mm3
</code></pre>
<p>Ok, time to go get the Mailman code.</p>
<p>First, define a bash function to help document our git HEAD’s as we go along:</p>
<pre><code>$ function whats-git-head {
b=$(git branch 2>/dev/null|grep '^*' | colrm 1 2)
echo "Branch is $b"
git log --date=iso --pretty=format:'HEAD of BRANCHSUBS is %h, %aN, %<(19,trunc)%ad, %<(120,trunc)%s' $* | head -1 | sed -e "s/BRANCHSUBS/$b/"
}
$ git clone https://gitlab.com/mailman/mailman.git
$ cd mailman
$ whats-git-head
Branch is master
HEAD of master is 9753361, Barry Warsaw, 2017-02-21 15:00:.., Merge branch 'diffcov' into 'master'
</code></pre>
<p>Set up python virtualenv’s:</p>
<pre><code>$ virtualenv -p /usr/bin/python2 env2
$ virtualenv -p /usr/bin/python3 env # no 3 at end
</code></pre>
<p>Check out these virtualenvs:</p>
<pre><code>$ bash # New shell
$ source env2/bin/activate
(env2) mm3@jessie:~/mailman$ python --version
Python 2.7.9
$ exit
$ bash
$ source env/bin/activate
(env) mm3@jessie:~/mailman$ python --version
Python 3.4.2
</code></pre>
<p>Python 3 is the one to use for the “main” mailman installation (we also need this in Python 2, see postorius configuration)</p>
<pre><code>(env) mm3@jessie:~/mailman$ pip install psycopg2
(env) mm3@jessie:~/mailman$ python setup.py install
(env) mm3@jessie:~/mailman$ exit
</code></pre>
<p>Install mailmanclient.</p>
<pre><code>$ pwd
/home/mm3/mailman
$ git clone https://gitlab.com/mailman/mailmanclient.git
$ cd mailmanclient
$ whats-git-head
Branch is master
HEAD of master is 15195ac, 2017-02-03, Barry Warsaw, Merge branch 'news' into 'master'
$ cd ~/mailman
$ source env2/bin/activate
(env2) mm3@jessie:~/mailman$ cd mailmanclient/
(env2) mm3@jessie:~/mailman/mailmanclient$ python setup.py install
</code></pre>
<p>(All else will be using Python 2, so we’ll stay in “env2”)</p>
<p>Install django-mailman3.</p>
<pre><code>(env2) mm3@jessie:~/mailman/mailmanclient$ cd ~/mailman
(env2) mm3@jessie:~/mailman$ git clone https://gitlab.com/mailman/django-mailman3.git
(env2) mm3@jessie:~/mailman$ cd django-mailman3
(env2) mm3@jessie:~/mailman/django-mailman3$ whats-git-head
Branch is master
HEAD of master is 60f551c, Aurélien Bompard, 2017-02-02 11:32:.., Make sure the middleware tests pass even with custom config
</code></pre>
<p>Before running setup.py, install this version of django. Version 1.10 causes trouble!</p>
<pre><code>(env2) mm3@jessie:~/mailman/django-mailman3$ pip install django==1.9
(env2) mm3@jessie:~/mailman/django-mailman3$ python setup.py install
</code></pre>
<p>Install postorius.</p>
<pre><code>(env2) mm3@jessie:~/mailman/django-mailman3$ cd ~/mailman
(env2) mm3@jessie:~/mailman$ git clone https://gitlab.com/mailman/postorius.git
(env2) mm3@jessie:~/mailman/$ cd postorius
(env2) mm3@jessie:~/mailman/postorius$ whats-git-head
Branch is master
HEAD of master is 6ffddf5, Florian Fuchs, 2017-02-18 06:54:.., Merge branch '3.1' into 'master'
(env2) mm3@jessie:~/mailman/django-mailman3$ python setup.py install
</code></pre>
<p>Install hyperkitty.</p>
<pre><code>(env2) mm3@jessie:~/mailman/django-mailman3$ cd ~/mailman
(env2) mm3@jessie:~/mailman/django-mailman3$ git clone https://gitlab.com/mailman/hyperkitty.git
(env2) mm3@jessie:~/mailman/django-mailman3$ cd hyperkitty
(env2) mm3@jessie:~/mailman/hyperkitty$ whats-git-head
Branch is master
HEAD of master is 45f6e70, Aurélien Bompard, 2017-02-10 15:58:.., Fix typo
(env2) mm3@jessie:~/mailman/hyperkitty$ pip install rcssmin
(env2) mm3@jessie:~/mailman/hyperkitty$ python setup.py install
</code></pre>
<p>Install mailman-hyperkitty, using Python 3!</p>
<pre><code>$ cd ~/mailman
$ source env/bin/activate
(env3) mm3@jessie:~/mailman/$ git clone https://github.com/hyperkitty/mailman-hyperkitty.git
(env3) mm3@jessie:~/mailman$ cd mailman-hyperkitty/
(env3) mm3@jessie:~/mailman/mailman-hyperkitty$ whats-git-head
Branch is master
HEAD of master is 10da29c, Aurélien Bompard, 2015-04-29 11:54:.., Version 1.0.0
(env) mm3@jessie:~/mailman/mailman-hyperkitty$ python setup.py install
</code></pre>
<p>Now we have downloaded all that we need. Next is configuration.</p>
<p>First, add a postgres user, add a postgres mm3 user with password and add a database to use.</p>
<pre><code>$ sudo -u postgres psql postgres
psql (9.4.10)
Type "help" for help.
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
# As postgres user
$ createuser -P mm3 # Enter a password e.g. pwdpwdpwd
$ createdb -O mm3 mm3db
$ cd ~/mailman
mm3@jessie:~/mailman$ source env/bin/activate # Need Python 3
(env) mm3@jessie:~/mailman$ mkdir mm3-root
(env) mm3@jessie:~/mailman$ cd mm3-root
(env) mm3@jessie:~/mailman$ mailman start
</code></pre>
<p>Change file var/etc/mailman.cfg; no leading slash; this is still in the mm3-root directory!</p>
<pre><code>(env) mm3@jessie:~/mailman$ cat > var/etc/mailman.cfg << END_MAILMAN_CFG
[devmode]
enabled: no
recipient: your.address@your.domain
[mta]
incoming: mailman.mta.postfix.LMTP
outgoing: mailman.mta.deliver.deliver
lmtp_host: 127.0.0.1
lmtp_port: 8024
smtp_host: localhost
smtp_port: 25
configuration: python:mailman.config.postfix
[database]
class: mailman.database.postgresql.PostgreSQLDatabase
url: postgres://mm3:pwdpwdpwd@localhost:5432/mm3db
END_MAILMAN_CFG
</code></pre>
<p>Then kill the mailman process, and restart</p>
<pre><code>(env) mm3@jessie:~/mailman$ mailman stop
Shutting down Mailman's master runner
(env) mm3@jessie:~/mailman/mm3-root$ mailman start
Starting Mailman's master runner
</code></pre>
<p>From now using Python 2 again.</p>
<pre><code>(env) mm3@jessie:~/mailman/mm3-root$ exit # New shell
$ cd ~/mailman
$ source env2/bin/activate
$ pip install psycopg2
(env2) mm3@jessie:~/mailman$ cd postorius
(env2) mm3@jessie:~/mailman/postorius $ cp -r example_project vanluga
</code></pre>
<p>In file vanluga/settings.py change</p>
<pre><code>SECRET_KEY = 'Use your own secret key"
DEBUG = False
ALLOWED_HOSTS = \['*', 'mail.vanlu.ga'\]
SECURE_HSTS_SECONDS=10
SECURE_CONTENT_TYPE_NOSNIFF=True
SECURE_BROWSER_XSS_FILTER=True
CSRF_COOKIE_HTTPONLY=True
X_FRAME_OPTIONS='DENY'
SECURE_HSTS_INCLUDE_SUBDOMAINS=True
USE_X_FORWARDED_HOST = True
SECURE_HSTS_SECONDS=10
SECURE_CONTENT_TYPE_NOSNIFF=True
SECURE_BROWSER_XSS_FILTER=True
</code></pre>
<p>If the server is set up for https, add these:</p>
<pre><code>SECURE_SSL_REDIRECT=True -- HTTPS ONLY
SESSION_COOKIE_SECURE=True -- HTTPS ONLY
CSRF_COOKIE_SECURE=True -- HTTPS ONLY
</code></pre>
<p>and set up</p>
<pre><code>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mm3db',
'USER': 'mm3',
'PASSWORD': 'pwdpwdpwd',
'HOST': 'localhost',
'PORT': '5432',
}
}
</code></pre>
<p>Find the line</p>
<pre><code>ROOT_URLCONF = 'urls'
</code></pre>
<p>and set it to – but only after running the next three commands:</p>
<pre><code>ROOT_URLCONF = 'vanluga.urls'
</code></pre>
<p>Change the line for DJANGO_SETTINGS_MODULE in file vanluga/wsgi.py:</p>
<pre><code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vanluga.settings")
</code></pre>
<p>Then run these:</p>
<pre><code>(env2) mm3@jessie:~/mailman/postorius $ python vanluga/manage.py migrate
(env2) mm3@jessie:~/mailman/postorius $ python vanluga/manage.py createsuperuser
</code></pre>
<p>Fill Username, password and email as desired. You will need to follow a verification link that is sent to the email; so better use one that works. Then it will say: “Superuser created successfully.”</p>
<p>Set up static files:</p>
<pre><code>(env2) mm3@jessie:~/mailman/postorius $ python vanluga/manage.py collectstatic
</code></pre>
<p>As root</p>
<pre><code>$ chown -R mm3:www-data /home/mm3/mailman/postorius/vanluga/static
</code></pre>
<p>Side topic; configuration of postfix (taken from http://thinlight.org/2012/03/10/postfix-only-allow-whitelisted-recipient-domains/). For development/test rides, find it convenient to use mailinator.com addresses but want to avoid sending emails to any other domain (bugs/misconfiguration/etc). Put this in /etc/postfix/recipient_domains:</p>
<pre><code>mailinator.com OK
mail.vanlu.ga OK
</code></pre>
<p>This in /etc/postfix/main.cf,</p>
<pre><code>smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_domains, reject
</code></pre>
<p>Run as root:</p>
<pre><code>$ postmap /etc/postfix/recipient_domains
$ service postfix restart
</code></pre>
<p>End side topic. Back to running postorius.</p>
<pre><code>(env2) mm3@jessie:~/mailman$ django-admin runserver 0.0.0.0:8000 --pythonpath vanluga --settings settings
</code></pre>
<p>In a browser, go to http://127.0.0.1:8000/admin/. Login as admin or whatever set up with the createsuperuser command above.</p>
<ul>
<li>Go to http://127.0.0.1:8000/admin/sites/site/add.</li>
<li>Enter Domain Name and Display Name as mail.vanlu.ga.</li>
<li>
<p>Click Save button</p>
</li>
<li>Go to http://127.0.0.1:8000/admin/django_mailman3/maildomain/add/.</li>
<li>Select Site as mail.vanlu.ga Enter Mail Domain mail.vanlu.ga.</li>
<li>
<p>Click Save</p>
</li>
<li>Go to http://127.0.0.1:8000/postorius/lists/.</li>
<li>Click green button “Create new domain” (URL postorius/domains/new/)</li>
<li>Enter mail.vanlu.ga in all three fields, Mail Host, Description and Web Host.</li>
<li>
<p>Click the Create Domain button</p>
</li>
<li>Go back to http://127.0.0.1:8000/postorius/lists/</li>
<li>Click the button Create New List</li>
<li>Enter List Name news</li>
<li>Mail Host mail.vanlu.ga</li>
<li>Description Testing</li>
<li>Check off Advertise this list in list index</li>
<li>Click the Create List button</li>
</ul>
<p>Add at end of file /etc/postfix/main.cf</p>
<pre><code>transport_maps = hash:/home/mm3/mailman/mm3-root/var/data/postfix_lmtp
local_recipient_maps = hash:/home/mm3/mailman/mm3-root/var/data/postfix_lmtp
relay_domains = hash:/home/mm3/mailman/mm3-root/var/data/postfix_domains
</code></pre>
<p>Run command, as root:</p>
<pre><code>$ service postfix restart
$ cd ~/mailman
$ source env2/bin/activate
(env2) mm3@jessie:~/mailman$ cd hyperkitty
(env2) mm3@jessie:~/mailman/hyperkitty$ cp -r example_project vanluga
</code></pre>
<p>Set in file vanluga/settings.py:</p>
<ol>
<li>SECRET_KEY = ‘mm3-mailman-hyperkitty-123’</li>
<li>ALLOWED_HOSTS: “mail.vanlu.ga”</li>
<li>MAILMAN_ARCHIVER_KEY: “MMMSecretArchiverAPIKey”</li>
<li>USE_X_FORWARDED_HOST = True</li>
<li>Change sassc to sass in the COMPRESS_PRECOMPILERS section (2 lines)</li>
<li>Set DATABASES as above</li>
</ol>
<p>Find the line</p>
<pre><code>ROOT_URLCONF = 'urls'
</code></pre>
<p>and set it to – but only after running the next three commands:</p>
<pre><code>ROOT_URLCONF = 'vanluga.urls'
</code></pre>
<pre><code>(env2) mm3@jessie:~/mailman/hyperkitty$ django-admin migrate --pythonpath vanluga --settings settings
(env2) mm3@jessie:~/mailman/hyperkitty$ pip install whoosh
(env2) mm3@jessie:~/mailman/hyperkitty$ python vanluga/manage.py collectstatic # Answer yes when prompted
</code></pre>
<p>Run as root, presumably:</p>
<pre><code>$ chown -R mm3:www-data /home/mm3/mailman/hyperkitty/vanluga/static/CACHE
$ chown -R mm3:www-data /home/mm3/mailman/hyperkitty/vanluga/static/hyperkitty
(env) mm3@jessie:~/mailman/$ cd ~/mailman/mailman-hyperkitty
(env) mm3@jessie:~/mailman/mailman-hyperkitty$ cat > mailman-hyperkitty.cfg <<END_HYPERKITTY_CFG
[general]
base_url: http://localhost:8002/hyperkitty/
api_key: MMMSecretArchiverAPIKey
END_HYPERKITTY_CFG
</code></pre>
<p>And add to file ~/mailman/mm3-root/var/etc/mailman.cfg :</p>
<pre><code>[archiver.hyperkitty]
class: mailman_hyperkitty.Archiver
enable: yes
configuration: /home/mm3/mailman/mailman-hyperkitty/mailman-hyperkitty.cfg
</code></pre>
<p>Restart mailman, see above.</p>
<p>Change the line for DJANGO_SETTINGS_MODULE in file vanluga/wsgi.py:</p>
<pre><code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vanluga.settings")
</code></pre>
<p>Run hyperkitty server.</p>
<pre><code>$ cd ~/mailman
$ source env2/bin/activate
(env2) mm3@jessie:~/mailman/hyperkitty$ cd hyperkitty
(env2) mm3@jessie:~/mailman/hyperkitty$ django-admin runserver 0.0.0.0:8002 --pythonpath vanluga --settings settings
</code></pre>
<p>Need to add crontab entries (based on ~/mailman/hyperkitty/vanluga/crontab)</p>
<pre><code>$ cat > vanluga/crontab <<END_CRONTAB
MAILTO=""
* * * * * cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs minutely --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
2,17,32,47 * * * * cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs quarter_hourly --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
@hourly cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs hourly --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
@daily cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs daily --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
@weekly cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs weekly --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
@monthly cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs monthly --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
@yearly cd /home/mm3/mailman/hyperkitty && /home/mm3/mailman/env2/bin/python /home/mm3/mailman/env2/bin/django-admin.py runjobs yearly --pythonpath /home/mm3/mailman/hyperkitty/vanluga --settings settings
END_CRONTAB
$ crontab vanluga/crontab
</code></pre>
<p>Put in nginx.conf:</p>
<pre><code>user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
server {
server_name localhost mail.vanlu.ga;
listen 100;
location /static/CACHE {
alias /home/mm3/mailman/hyperkitty/vanluga/static/CACHE;
expires max;
access_log off;
}
location /static/hyperkitty {
alias /home/mm3/mailman/hyperkitty/vanluga/static/hyperkitty;
expires max;
access_log off;
}
location /hyperkitty {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8002/hyperkitty;
}
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
}
}
</code></pre>
<p>To search visit URL http://mail.vanlu.ga/hyperkitty/search .</p>
</body>
</html>