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