Merge branch 'release/2.1.0' into 'stable'
[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`
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 ## Configuring Pleroma
48
49 Create a user for Pleroma:
50
51 ```
52 # groupadd pleroma
53 # useradd -d /home/pleroma -m -g pleroma -s /usr/pkg/bin/mksh pleroma
54 # echo 'export LC_ALL="en_GB.UTF-8"' >> /home/pleroma/.profile
55 # su -l pleroma -c $SHELL
56 ```
57
58 Clone the repository:
59
60 ```
61 $ cd /home/pleroma
62 $ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
63 ```
64
65 Configure Pleroma. Note that you need a domain name at this point:
66
67 ```
68 $ cd /home/pleroma/pleroma
69 $ mix deps.get
70 $ mix pleroma.instance gen # You will be asked a few questions here.
71 ```
72
73 Since Postgres is configured, we can now initialize the database. There should
74 now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
75 *change the password* to a password of your choice. Make sure it is secure, since
76 it'll be protecting your database. Now initialize the database:
77
78 ```
79 $ sudo -Hu pgsql -g pgsql psql -f config/setup_db.psql
80 ```
81
82 Postgres allows connections from all users without a password by default. To
83 fix this, edit `/usr/pkg/pgsql/data/pg_hba.conf`. Change every `trust` to
84 `password`.
85
86 Once this is done, restart Postgres with `# /etc/rc.d/pgsql restart`.
87
88 Run the database migrations.
89 You will need to do this whenever you update with `git pull`:
90
91 ```
92 $ MIX_ENV=prod mix ecto.migrate
93 ```
94
95 ## Configuring nginx
96
97 Install the example configuration file
98 `/home/pleroma/pleroma/installation/pleroma.nginx` to
99 `/usr/pkg/etc/nginx.conf`.
100
101 Note that it will need to be wrapped in a `http {}` block. You should add
102 settings for the nginx daemon outside of the http block, for example:
103
104 ```
105 user nginx nginx;
106 error_log /var/log/nginx/error.log;
107 worker_processes 4;
108
109 events {
110 }
111 ```
112
113 Edit the defaults:
114
115 * Change `ssl_certificate` and `ssl_trusted_certificate` to
116 `/etc/nginx/tls/fullchain`.
117 * Change `ssl_certificate_key` to `/etc/nginx/tls/key`.
118 * Change `example.tld` to your instance's domain name.
119
120 ## Configuring acme.sh
121
122 We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
123
124 First, get your account fingerprint:
125
126 ```
127 $ sudo -Hu nginx -g nginx acme.sh --register-account
128 ```
129
130 You need to add the following to your nginx configuration for the server
131 running on port 80:
132
133 ```
134 location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
135 default_type text/plain;
136 return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
137 }
138 ```
139
140 Replace the string after after `$1.` with your fingerprint.
141
142 Start nginx:
143
144 ```
145 # /etc/rc.d/nginx start
146 ```
147
148 It should now be possible to issue a cert (replace `example.com`
149 with your domain name):
150
151 ```
152 $ sudo -Hu nginx -g nginx acme.sh --issue -d example.com --stateless
153 ```
154
155 Let's add auto-renewal to `/etc/daily.local`
156 (replace `example.com` with your domain):
157
158 ```
159 /usr/pkg/bin/sudo -Hu nginx -g nginx \
160 /usr/pkg/sbin/acme.sh -r \
161 -d example.com \
162 --cert-file /etc/nginx/tls/cert \
163 --key-file /etc/nginx/tls/key \
164 --ca-file /etc/nginx/tls/ca \
165 --fullchain-file /etc/nginx/tls/fullchain \
166 --stateless
167 ```
168
169 ## Creating a startup script for Pleroma
170
171 Copy the startup script to the correct location and make sure it's executable:
172
173 ```
174 # cp /home/pleroma/pleroma/installation/netbsd/rc.d/pleroma /etc/rc.d/pleroma
175 # chmod +x /etc/rc.d/pleroma
176 ```
177
178 Add the following to `/etc/rc.conf`:
179
180 ```
181 pleroma=YES
182 pleroma_home="/home/pleroma"
183 pleroma_user="pleroma"
184 ```
185
186 Run `# /etc/rc.d/pleroma start` to start Pleroma.
187
188 ## Conclusion
189
190 Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
191
192 If you need further help, contact niaa on freenode.
193
194 Make sure your time is in sync, or other instances will receive your posts with
195 incorrect timestamps. You should have ntpd running.
196
197 ## Instances running NetBSD
198
199 * <https://catgirl.science>
200
201 #### Further reading
202
203 {! backend/installation/further_reading.include !}
204
205 ## Questions
206
207 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**.