-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.muse
674 lines (508 loc) · 18.6 KB
/
install.muse
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
#title How to install Amusewiki
#authors Marco Pessotto; Alexander Krotov;
#author Marco Pessotto, Alexander Krotov
#lang en
#topics doc, howto
#teaser Installation and post-installation configuration for various OS
#notes This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit [[http://creativecommons.org/licenses/by-sa/4.0/]] or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
The recommended way to install Amusewiki is via
[[https://packages.amusewiki.org][Debian repository]].
Since October 2020, Amusewiki installs a stripped down *TeX~~Live!*
which greatly reduces the installation size.
On a clean Debian Buster installation, which takes about 1Gb of space,
following the procedure described at
[[https://packages.amusewiki.org][packages.amusewiki.org]], installing
Amusewiki takes 308Mb of archives resulting in 920Mb of space used,
plus 160Mb of extra fonts, ending up with a total disk usage of about
2.2Gb.
However, please keep in mind that Amusewiki produces a lot of files,
so for a working instance the recommended *minimum* free space would
be something like 5Gb.
If you want to install manually, read on. If you need to do some
post-installation tweaking for ports and webserver logging, jump to
the [[#configuration][configuration section]]. Otherwise feel free to
skip this document entirely.
*** General installation
The procedure is fully automated, so start it, check if it bails
out at the beginning, forget about it for some time (run it under
[[https://www.gnu.org/software/screen/][screen]]), then come back later
and finish it up to complete it for the operations which require root
privileges (notably the webserver configuration).
You can speed up the process by installing TeX Live from the OS
repositories, which is the suggested approach because this way the
security fixes are delegated to the standard tools.
Amusewiki installation is similar for all <verbatim>*nix</verbatim>
operating systems, but you may want to additionally consult
[[#specific][OS-specific instructions section]] which contain instructions
for less common operating systems. Windows is not supported in any way.
**** Install prerequisites
In addition, the following software should be installed:
- a database ([[https://www.mysql.com/][MySQL]],
[[https://www.postgresql.org/][PostgreSQL]],
[[https://www.sqlite.org/][SQLite]] are supported)
- [[https://www.perl.org/][Perl]] and
[[https://metacpan.org/pod/Carton][Carton]]:
[[https://packages.debian.org/stable/perl/carton][=carton=]]
package on Debian
- fontconfig (install it before installing TeX Live)
- ghostscript (for preview generation)
- a mime-info database: =shared-mime-info= on Debian
- a dedicated system user (with a clean home) which is going to run the site
- SSL binaries and development libraries (=openssl= and =libssl-dev=)
- Xapian libraries and development files (=xapian-tools= =libxapian-dev=)
- commonly used utilities: =unzip=, =wget=, =git=, =rsync=
- widely used libraries: =libxml2-dev= =libexpat1-dev= =zlib1g-dev=
=libjpeg-dev= =libpng-dev= for =XML::LibXML= and =Imager=
- =cgit= if the distro provides it
- a webserver, =nginx= is the suggestion (but see below)
- TeX Live full either from system repo or installed with the provided script
So:
{{{
adduser --disabled-password amusewiki
apt install --no-install-recommends git carton ghostscript shared-mime-info openssl libssl-dev \
xapian-tools libxapian-dev unzip wget rsync build-essential cpanminus \
cgit libxml2-dev libexpat1-dev zlib1g-dev libjpeg-dev libpng-dev nginx fontconfig
}}}
Log in as the user you want to run the site.
Unpack the sources (or clone the repo) and change directory into them.
**** Install TeX Live
If you want to install TeX Live from the installer, run:
{{{
./script/install-texlive.sh
}}}
It will install the needed binaris and packages under =local/=.
**** Run the Amusewiki installer
Run installation script to check that you have installed prerequisites
and complete the installation:
{{{
./script/install.sh
}}}
**** Create the database
#mysql
Create a database for the application. E.g., for MySQL/MariaDB:[1]
[1] Since May 2023, we suggest to use =utf8mb4= instead of =utf8=. If
you want to upgrade from utf8 to utf8mb4, please take a look at
=script/convert-mysql-to-utf8mb4.my.sql= in the root of the
distribution, which contains the instructions for the upgrade.
{{{
MariaDB [(none)]> CREATE DATABASE amuse CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON amuse.* TO amusewiki@localhost IDENTIFIED BY 'Pa55Word';
}}}
#psql
Or, for PostgreSQL:
Login as root.
{{{
su - postgres
psql
create user amusewiki with password 'XXXX';
create database amusewiki owner amusewiki;
}}}
For SQLite no setup is required.
Copy =dbic.yaml.<dbtype>.example= to =dbic.yaml= and adjust the
credentials, and =chmod= it to =0600=. (For SQLite is good as it is).
**** Configure initial site
If you have multiple Amusewiki instances (please note, multiple sites
are just fine on a single instance) on the same machine,
[[#multiple][see below]] before proceeding (you probably want to tweak
the configuration).
Configure initial site with:
{{{
./script/configure.sh [ hostname ]
}}}
Please note that the installation procedure will create a mirror of
amusewiki.org under the subdomain amusewiki.<your domain>, where <your
domain> is the output of =hostname -d=. Nothing you can’t change later
from the admin console, but you need to access it. You can pass the
desired hostname as the first argument to the configure script.
*** Start the application
**** Starting the application manually
To set the number of FCGI workers, set the environment variable
AMW_WORKERS (defaults to 3).
{{{
export AMW_WORKERS=5
}}}
To start/stop/restart the application:
{{{
./init-all.sh start
./init-all.sh stop
./init-all.sh restart
}}}
This is not needed if you use systemd.
**** Starting the application with systemd
If your OS uses systemd for initialization, you can generate systemd
units with
{{{
script/generate-systemd-unit-files
}}}
It will generate unit files for three services:
- amusewiki-web
- amusewiki-jobber
- amusewiki-cgit
Follow the instructions printed on the screen to enable
=amusewiki-web= and =amusewiki-jobber=. Do *not* enable
=amusewiki-cgit=. cgit is managed by the web server, which we’ll
configure in the next section.
**** Web server configuration
The supported and recommended setup is nginx + FCGI. The FCGI setup
should work with Apache HTTP Server and Caddy Server as well (see
below).
***** Nginx configuration
To regenerate the nginx configuration after adding a site:
{{{
carton exec script/amusewiki-generate-nginx-conf
}}}
Follow the printed instructions to install generated configuration.
***** Apache
Sample configuration. You need =mod_proxy= and =mod_proxy_fcgi= loaded.
{{{
<VirtualHost *:80>
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /usr/share/perl5/AmuseWikiFarm/root/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# serve static from root
ProxyPass /static !
ProxyFCGIBackendType GENERIC
ProxyFCGISetEnvIf true SCRIPT_NAME
# Correct the socket path if needed, but leave the fcgi://localhost/ intact
ProxyPass "/" "unix:/var/lib/amusewiki/amusewiki.socket|fcgi://localhost/"
</VirtualHost>
}}}
***** Caddy configuration
Another easy to setup webserver is [[https://caddyserver.com][Caddy]],
but you will have to configure it manually and your configurtion may
become incomplete in the future.
Here, Amusewiki is assumed to be installed in =/home/amusewiki/amusewiki/= and hostname is =amusewiki.local=.
After [[https://caddyserver.com/docs/install][installing Caddy]],
create a =Caddyfile= with the correct paths to the webserver root and
to the FCGI socket.
For Caddy Version 1 (in this example we're using a sample amusewiki
install from git):
{{{
amusewiki.local:8080
tls off
log ./access.log
errors ./error.log
root /usr/home/amusewiki/amusewiki/root
fastcgi / unix:/usr/home/amusewiki/amusewiki/var/amw.sock {
except /static/
except /git/
}
}}}
For Caddy Version 2 (in this example with a system-wide installation
via [[http://packages.amusewiki.org/][Debian package]]):
{{{
http://amusewiki.local:8080 {
@static {
path /static/*
}
@fcgi {
not path /static/*
}
file_server @static {
root /usr/share/perl5/AmuseWikiFarm/root/
}
reverse_proxy @fcgi unix//var/lib/amusewiki/amusewiki.socket {
transport fastcgi
}
}
}}}
Start =caddy=.
#configuration
*** Additional configuration
**** Configuration file
Normally, you don’t need to change anything. However, may need to do
some tweaking to the webserver configuration. This is done via the
configuration file.
If amusewiki was installed with a debian package, the location is
=/etc/amusewiki.conf= otherwise you should create a file called
=amusewikifarm_local.conf= in the application directory, which will
override the existing settings in =amusewikifarm.conf=
Example with the defaults:
{{{
<Model::Webserver>
## cgit port
cgit_port 9015
## nginx log format
log_format combined
## nginx root
nginx_root /etc/nginx
## string to identify this installation
instance_name amusewikidebian
webserver_root /usr/share/perl5/AmuseWikiFarm/root
fcgi_socket /var/lib/amusewiki/amusewiki.socket
</Model::Webserver>
}}}
**** Mail with SMTP
You need to set the desired parameter as environment variable (in the
systemd unit file or in the user starting the application). See
[[https://metacpan.org/pod/Email::Sender::Manual::QuickStart]] and
[[https://metacpan.org/pod/Email::Sender::Transport::SMTP]] for details.
Previously we used the application config file, but that’s sloppy
because it prevents the jobber to send mails properly.
Example:
{{{
$ export EMAIL_SENDER_TRANSPORT=SMTP
$ export EMAIL_SENDER_TRANSPORT_host=smtp.example.com
$ export EMAIL_SENDER_TRANSPORT_port=2525
$ export EMAIL_SENDER_TRANSPORT_sasl_username=XXXX
$ export EMAIL_SENDER_TRANSPORT_sasl_password=XXXX
./init-all.sh restart
}}}
If you use systemd unit files to start/stop/restart the application,
you need to override them and set the environment variables instead.
{{{
cp /lib/systemd/system/amusewiki-web.service \
/lib/systemd/system/amusewiki-jobber.service \
/etc/systemd/system
}}}
Add in the =[Service]= stanza the needed variables to both unit files, like this:
{{{
Environment="EMAIL_SENDER_TRANSPORT=SMTP"
Environment="EMAIL_SENDER_TRANSPORT_host=smtp.example.com"
Environment="EMAIL_SENDER_TRANSPORT_port=2525"
Environment="EMAIL_SENDER_TRANSPORT_sasl_username=XXXX"
Environment="EMAIL_SENDER_TRANSPORT_sasl_password=XXXX"
}}}
and reload systemd with =systemctl daemon-reload=
#multiple
**** Multiple installations
If you run a Debian machine and you have only one instance running and
if you have the port 9015 free, you don’t need any of this.
Please note: “multiple instances” doesn’t mean “multiple sites”. On a
single instance you can have as many sites as you want.
The interaction between nginx and the application, including cgit, is
controlled by the Webserver model. You can configure it creating a
file in the application root named =amusewikifarm_local.conf= with
this content (here listed with the defaults).
{{{
<Model::Webserver>
# cgit port
cgit_port 9015
log_format combined
nginx_root /etc/nginx
instance_name amusewiki
fcgiwrap_socket /var/run/fcgiwrap.socket
</Model::Webserver>
}}}
The instance_name is just a string used to create the nginx
configuration files to avoid conflicts with other installations. So
you may have one instance named “testing” and the other “live”.
#specific
*** OS-specific instructions
The following sections contain installation instructions for operating
systems other than Debian. Note that these sections may be outdated,
so read general installation instructions first.
**** FreeBSD 12.0
Install prerequisites:
{{{
pkg install perl5 p5-App-cpanminus \
p5-carton git texlive-full \
cgit GraphicsMagick shared-mime-info \
xapian-core xapian-bindings \
nginx fcgiwrap unzip rsync wget bash
}}}
Create amusewiki user:
{{{
[root@freebsd ~]# adduser
Username: amusewiki
Full name: Amusewiki
Uid (Leave empty for default):
Login group [amusewiki]:
Login group is amusewiki. Invite amusewiki into other groups? []:
Login class [default]:
Shell (sh csh tcsh zsh rzsh bash rbash git-shell nologin) [sh]: bash
Home directory [/home/amusewiki]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]:
Username : amusewiki
Password : <disabled>
Full Name : Amusewiki
Uid : 1001
Class :
Groups : amusewiki
Home : /home/amusewiki
Home Mode :
Shell : /usr/local/bin/bash
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (amusewiki) to the user database.
Add another user? (yes/no): no
Goodbye!
}}}
Add to =/etc/rc.conf=
{{{
nginx_enable=YES
fcgiwrap_enable=YES
fcgiwrap_user=www
fcgiwrap_socket="unix:/var/run/fcgiwrap/socket"
# create an include sites-enabled directory for nginx and log dir
mkdir -p /usr/local/etc/nginx/sites-enabled
mkdir -p /var/log/nginx/
# and add an include directive in nginx.conf inside the http { } stanza, at the end.
# include /usr/local/etc/nginx/sites-enabled/*;
vi /usr/local/etc/nginx/nginx.conf
}}}
And start the services
{{{
service nginx start
service fcgiwrap start
}}}
{{{
su - amusewiki
git clone https://github.com/melmothx/amusewiki.git
cd amusewiki
CXX=c++ ./script/install.sh
# create the config
cat << EOF > amusewikifarm_local.conf
<Model::Webserver>
nginx_root /usr/local/etc/nginx
fcgiwrap_socket /var/run/fcgiwrap/socket
</Model::Webserver>
EOF
}}}
Then decide to which hostname you want to serve this and run
{{{
./script/configure.sh amw.localdomain
}}}
Read the output (you'll need to configure a database), do what it says
and run it again, taking note of the credentials, and follow the
instructions.
If you want to use MySQL, run as root:
{{{
pkg install mysql57-server
echo 'mysql_enable=YES' >> /etc/rc.conf
service mysql-server start
cat ~/.mysql_secret # see password
mysql -h localhost -p
}}}
Create the database as described above in the [[#mysql][generic section]]
and then finalize the configuration with the amusewiki user:
{{{
# su - amusewiki
$ cd amusewiki
$ cpanm -L local DBD::mysql
$ cp dbic.yaml.mysql.example dbic.yaml
$ vi dbic.yaml # edit db credentials
$ ./script/configure.sh amw.localdomain # reconfigure
$ ./init-all start
}}}
For PostgreSQL, run as root:
{{{
pkg install postgresql96-server
echo 'postgresql_enable=YES' >> /etc/rc.conf
service postgresql initdb
service postgresql start
su - postgres
}}}
Create the database as described above in the [[#psql][generic section]]
and then finalize the configuration with the amusewiki user:
{{{
# su - amusewiki
$ cd amusewiki
$ cpanm -L local DBD::Pg
$ cp dbic.yaml.pg.example dbic.yaml
$ vi dbic.yaml # edit db credentials
$ ./script/configure.sh amw.localdomain # reconfigure
$ ./init-all start
}}}
**** CentOS 7
Most of these instructions will apply to other GNU/Linux systems with
systemd and SELinux.
TeX Live is obsolete, so we will install it from CTAN. The same goes
with Perl.
From a fresh install:
{{{
# yum install epel-release
# yum install git nginx perl-local-lib sqlite cgit \
perl-App-cpanminus fontconfig GraphicsMagick ImageMagick shared-mime-info openssl openssl-devel \
xapian-core xapian-core-devel unzip wget libxml2 libxml2-devel expat-devel \
policycoreutils setroubleshoot
# yum groupinstall 'Development Tools'
}}}
Tweak nginx configuration to conform to Debian standard
{{{
# mkdir /etc/nginx/sites-enabled
}}}
Modify =/etc/nginx/nginx.conf= adding this line:
{{{
include /etc/nginx/sites-enabled/*;
}}}
Right after =include /etc/nginx/conf.d/*.conf;=
(Probably you may also want to add =client_max_body_size 8m;= as the
default is way too low).
Start nginx:
{{{
# systemctl enable nginx
# systemctl start nginx
}}}
Open the firewall
{{{
# firewall-cmd --get-active-zones
# firewall-cmd --zone=public --add-service=http --permanent
# firewall-cmd --zone=public --add-service=https --permanent
# firewall-cmd --reload
}}}
Prepare the installation directory for your user (say =amusewiki=, but
any other will do).
Please note that we install it under =/var/www/= to avoid problems
with SELinux.
{{{
# mkdir /var/www/amusewiki
# chown amusewiki:amusewiki /var/www/amusewiki
}}}
As the user which is going to run Amusewiki, install a fresh Perl.
This way we simplify and make our install independent from the base
system, which is lacking way too many modules.
{{{
$ eval `perl -Mlocal::lib`
$ cpanm Perl::Build
$ perl-build -j 3 --test 5.24.1 $HOME/amw-perl
$ cd /vaw/www/amusewiki
$ git clone https://github.com/melmothx/amusewiki.git
$ cd amusewiki # you're now in /vaw/www/amusewiki/amusewiki, our app home
$ ./script/install-texlive.sh # install texlive
$ echo 'export PATH=$HOME/amw-perl/bin:$HOME/texlive/2018/bin/x86_64-linux:$PATH' >> $HOME/.bashrc
$ chmod 755 $HOME # open the home so plackup is accessible to nginx
}}}
Logout and login again and check the program paths to point to the newly installed ones
{{{
$ which perl # should be: ~/amw-perl/bin/perl
$ which xelatex # should be ~/texlive/2018/bin/x86_64-linux/xelatex or equivalent
}}}
Install cpanm and the dependencies
{{{
$ perl -MCPAN -e 'install Carton'
$ which carton # should be ~/amw-perl/bin/carton
$ cd /var/www/amusewiki/amusewiki/
$ ./script/install.sh
}}}
Decide the initial server name to serve Amusewiki (to get access to
the admin), e.g. amw.localdomain.
See above if you want a MySQL or PostgreSQL database. The following
command will create a sample site with the current Amusewiki
documentation.
{{{
$ ./script/configure.sh amw.localdomain
}}}
Remove the cgit wrapper, we’re going to install systemd unit files.
{{{
$ rm root/git/cgit.cgi
$ ./script/generate-systemd-unit-files
$ carton exec ./script/amusewiki-generate-nginx-conf
}}}
Read the output and install the fresh nginx configuration.
Finally, open the permission for SELinux. As root:
{{{
cd /var/www/amusewiki/amusewiki/doc/centos/
checkmodule -M -m -o amusewiki.mod amusewiki.te
semodule_package -o amusewiki.pp -m amusewiki.mod
semodule -i amusewiki.pp
}}}
Reboot to be sure everything is ok, open with a browser the location
you configured (say, =amw.localdomain=, you may want to add the entry
=/etc/hosts= to access it) and login.
You probably want to head to the admin panel under =/admin/sites= to
create a new site.