Adjusted MediaProxyControllerTest to gracefully fail on missing dependencies. Install...
[akkoma] / docs / installation / netbsd_en.md
1 # Installing on NetBSD
2
3 ## Required software
4
5 pkgin should have been installed by the NetBSD installer if you selected
6 the right options. If it isn't installed, install it using pkg_add.
7
8 Note that `postgresql11-contrib` is needed for the Postgres extensions
9 Pleroma uses.
10
11 The `mksh` shell is needed to run the Elixir `mix` script.
12
13 `# pkgin install acmesh elixir git-base git-docs mksh nginx postgresql11-server postgresql11-client postgresql11-contrib sudo ffmpeg4 ImageMagick`
14
15 You can also build these packages using pkgsrc:
16 ```
17 databases/postgresql11-contrib
18 databases/postgresql11-client
19 databases/postgresql11-server
20 devel/git-base
21 devel/git-docs
22 devel/cmake
23 lang/elixir
24 security/acmesh
25 security/sudo
26 shells/mksh
27 www/nginx
28 ```
29
30 Copy the rc.d scripts to the right directory:
31
32 ```
33 # cp /usr/pkg/share/examples/rc.d/nginx /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d
34 ```
35
36 Add nginx and Postgres to `/etc/rc.conf`:
37
38 ```
39 nginx=YES
40 pgsql=YES
41 ```
42
43 ## Configuring postgres
44
45 First, run `# /etc/rc.d/pgsql start`. Then, `$ sudo -Hu pgsql -g pgsql createdb`.
46
47 ### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md))
48
49 `# pkgin install ImageMagick ffmpeg4 p5-Image-ExifTool`
50
51 ## Configuring Pleroma
52
53 Create a user for Pleroma:
54
55 ```
56 # groupadd pleroma
57 # useradd -d /home/pleroma -m -g pleroma -s /usr/pkg/bin/mksh pleroma
58 # echo 'export LC_ALL="en_GB.UTF-8"' >> /home/pleroma/.profile
59 # su -l pleroma -c $SHELL
60 ```
61
62 Clone the repository:
63
64 ```
65 $ cd /home/pleroma
66 $ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
67 ```
68
69 Configure Pleroma. Note that you need a domain name at this point:
70
71 ```
72 $ cd /home/pleroma/pleroma
73 $ mix deps.get
74 $ mix pleroma.instance gen # You will be asked a few questions here.
75 ```
76
77 Since Postgres is configured, we can now initialize the database. There should
78 now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
79 *change the password* to a password of your choice. Make sure it is secure, since
80 it'll be protecting your database. Now initialize the database:
81
82 ```
83 $ sudo -Hu pgsql -g pgsql psql -f config/setup_db.psql
84 ```
85
86 Postgres allows connections from all users without a password by default. To
87 fix this, edit `/usr/pkg/pgsql/data/pg_hba.conf`. Change every `trust` to
88 `password`.
89
90 Once this is done, restart Postgres with `# /etc/rc.d/pgsql restart`.
91
92 Run the database migrations.
93 You will need to do this whenever you update with `git pull`:
94
95 ```
96 $ MIX_ENV=prod mix ecto.migrate
97 ```
98
99 ## Configuring nginx
100
101 Install the example configuration file
102 `/home/pleroma/pleroma/installation/pleroma.nginx` to
103 `/usr/pkg/etc/nginx.conf`.
104
105 Note that it will need to be wrapped in a `http {}` block. You should add
106 settings for the nginx daemon outside of the http block, for example:
107
108 ```
109 user nginx nginx;
110 error_log /var/log/nginx/error.log;
111 worker_processes 4;
112
113 events {
114 }
115 ```
116
117 Edit the defaults:
118
119 * Change `ssl_certificate` and `ssl_trusted_certificate` to
120 `/etc/nginx/tls/fullchain`.
121 * Change `ssl_certificate_key` to `/etc/nginx/tls/key`.
122 * Change `example.tld` to your instance's domain name.
123
124 ## Configuring acme.sh
125
126 We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
127
128 First, get your account fingerprint:
129
130 ```
131 $ sudo -Hu nginx -g nginx acme.sh --register-account
132 ```
133
134 You need to add the following to your nginx configuration for the server
135 running on port 80:
136
137 ```
138 location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
139 default_type text/plain;
140 return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
141 }
142 ```
143
144 Replace the string after after `$1.` with your fingerprint.
145
146 Start nginx:
147
148 ```
149 # /etc/rc.d/nginx start
150 ```
151
152 It should now be possible to issue a cert (replace `example.com`
153 with your domain name):
154
155 ```
156 $ sudo -Hu nginx -g nginx acme.sh --issue -d example.com --stateless
157 ```
158
159 Let's add auto-renewal to `/etc/daily.local`
160 (replace `example.com` with your domain):
161
162 ```
163 /usr/pkg/bin/sudo -Hu nginx -g nginx \
164 /usr/pkg/sbin/acme.sh -r \
165 -d example.com \
166 --cert-file /etc/nginx/tls/cert \
167 --key-file /etc/nginx/tls/key \
168 --ca-file /etc/nginx/tls/ca \
169 --fullchain-file /etc/nginx/tls/fullchain \
170 --stateless
171 ```
172
173 ## Creating a startup script for Pleroma
174
175 Copy the startup script to the correct location and make sure it's executable:
176
177 ```
178 # cp /home/pleroma/pleroma/installation/netbsd/rc.d/pleroma /etc/rc.d/pleroma
179 # chmod +x /etc/rc.d/pleroma
180 ```
181
182 Add the following to `/etc/rc.conf`:
183
184 ```
185 pleroma=YES
186 pleroma_home="/home/pleroma"
187 pleroma_user="pleroma"
188 ```
189
190 Run `# /etc/rc.d/pleroma start` to start Pleroma.
191
192 ## Conclusion
193
194 Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
195
196 If you need further help, contact niaa on freenode.
197
198 Make sure your time is in sync, or other instances will receive your posts with
199 incorrect timestamps. You should have ntpd running.
200
201 ## Instances running NetBSD
202
203 * <https://catgirl.science>
204
205 #### Further reading
206
207 {! backend/installation/further_reading.include !}
208
209 ## Questions
210
211 Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.