logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

netbsd_en.md (9228B)


  1. # Installing on NetBSD
  2. {! backend/installation/generic_dependencies.include !}
  3. # Installation options
  4. Currently there are two options available for NetBSD: manual installation (from source) or using experimental package from [pkgsrc-wip](https://github.com/NetBSD/pkgsrc-wip/tree/master/pleroma).
  5. WIP package can be installed via pkgsrc and can be crosscompiled for easier binary distribution. Source installation most probably will be restricted to a single machine.
  6. ## pkgsrc installation
  7. WIP package creates Mix.Release (similar to how Docker images are built) but doesn't bundle Erlang runtime, listing it as a dependency instead. This allows for easier and more modular installations, especially on weaker machines. Currently this method also does not support all features of `pleroma_ctl` command (like changing installation type or managing frontends) as NetBSD is not yet a supported binary flavour of Pleroma's CI.
  8. In any case, you can install it the same way as any other `pkgsrc-wip` package:
  9. ```
  10. cd /usr/pkgsrc
  11. git clone --depth 1 git://wip.pkgsrc.org/pkgsrc-wip.git wip
  12. cp -rf wip/pleroma www
  13. cp -rf wip/libvips graphics
  14. cd /usr/pkgsrc/www/pleroma
  15. bmake && bmake install
  16. ```
  17. Use `bmake package` to create a binary package. This can come especially handy if you're targeting embedded or low-power systems and are crosscompiling on a more powerful machine.
  18. > Note: Elixir has [endianness bug](https://github.com/elixir-lang/elixir/issues/2785) which requires it to be compiled on a machine with the same endianness. In other words, package crosscompiled on amd64 (little endian) won't work on powerpc or sparc machines (big endian). While _in theory™_ nothing catastrophic should happen, one can see that for example regexes won't work properly. Some distributions just strip this warning away, so it doesn't bother the users... anyway, you've been warned.
  19. ## Source installation
  20. pkgin should have been installed by the NetBSD installer if you selected
  21. the right options. If it isn't installed, install it using `pkg_add`.
  22. Note that `postgresql11-contrib` is needed for the Postgres extensions
  23. Pleroma uses.
  24. > Note: you can use modern versions of PostgreSQL. In this case, just use `postgresql16-contrib` and so on.
  25. The `mksh` shell is needed to run the Elixir `mix` script.
  26. `# pkgin install acmesh elixir git-base git-docs mksh nginx postgresql11-server postgresql11-client postgresql11-contrib sudo ffmpeg4 ImageMagick`
  27. You can also build these packages using pkgsrc:
  28. ```
  29. databases/postgresql11-contrib
  30. databases/postgresql11-client
  31. databases/postgresql11-server
  32. devel/git-base
  33. devel/git-docs
  34. devel/cmake
  35. lang/elixir
  36. security/acmesh
  37. security/sudo
  38. shells/mksh
  39. www/nginx
  40. ```
  41. Create a user for Pleroma:
  42. ```
  43. # groupadd pleroma
  44. # useradd -d /home/pleroma -m -g pleroma -s /usr/pkg/bin/mksh pleroma
  45. # echo 'export LC_ALL="en_GB.UTF-8"' >> /home/pleroma/.profile
  46. # su -l pleroma -c $SHELL
  47. ```
  48. Clone the repository:
  49. ```
  50. $ cd /home/pleroma
  51. $ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
  52. ```
  53. Get deps and compile:
  54. ```
  55. $ cd /home/pleroma/pleroma
  56. $ export MIX_ENV=prod
  57. $ mix deps.get
  58. $ mix compile
  59. ```
  60. ## Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md))
  61. `# pkgin install ImageMagick ffmpeg4 p5-Image-ExifTool`
  62. or via pkgsrc:
  63. ```
  64. graphics/p5-Image-ExifTool
  65. graphics/ImageMagick
  66. multimedia/ffmpeg4
  67. ```
  68. # Configuration
  69. ## Understanding $PREFIX
  70. From now on, you may encounter `$PREFIX` variable in the paths. This variable indicates your current local pkgsrc prefix. Usually it's `/usr/pkg` unless you configured it otherwise. Translating to pkgsrc's lingo, it's called `LOCALBASE`, which essentially means the same this. You may want to set it up for your local shell session (this uses `mksh` which should already be installed as one of the required dependencies):
  71. ```
  72. $ export PREFIX=$(pkg_info -Q LOCALBASE mksh)
  73. $ echo $PREFIX
  74. /usr/pkg
  75. ```
  76. ## Setting up your instance
  77. Now, you need to configure your instance. During this initial configuration, you will be asked some questions about your server. You will need a domain name at this point; it doesn't have to be deployed, but changing it later will be very cumbersome.
  78. If you've installed via pkgsrc, `pleroma_ctl` should already be in your `PATH`; if you've installed from source, it's located at `/home/pleroma/pleroma/release/bin/pleroma_ctl`.
  79. ```
  80. $ su -l pleroma
  81. $ pleroma_ctl instance gen --output $PREFIX/etc/pleroma/config.exs --output-psql /tmp/setup_db.psql
  82. ```
  83. During installation, you will be asked about static and upload directories. Don't forget to create them and update permissions:
  84. ```
  85. mkdir -p /var/lib/pleroma/uploads
  86. chown -R pleroma:pleroma /var/lib/pleroma
  87. ```
  88. ## Setting up the database
  89. First, run `# /etc/rc.d/pgsql start`. Then, `$ sudo -Hu pgsql -g pgsql createdb`.
  90. We can now initialize the database. You'll need to edit generated SQL file from the previous step. It's located at `/tmp/setup_db.psql`.
  91. Edit this file, and *change the password* to a password of your choice. Make sure it is secure, since
  92. it'll be protecting your database. Now initialize the database:
  93. ```
  94. $ sudo -Hu pgsql -g pgsql psql -f /tmp/setup_db.psql
  95. ```
  96. Postgres allows connections from all users without a password by default. To
  97. fix this, edit `$PREFIX/pgsql/data/pg_hba.conf`. Change every `trust` to
  98. `password`.
  99. Once this is done, restart Postgres with `# /etc/rc.d/pgsql restart`.
  100. Run the database migrations.
  101. ### pkgsrc installation
  102. ```
  103. pleroma_ctl migrate
  104. ```
  105. ### Source installation
  106. You will need to do this whenever you update with `git pull`:
  107. ```
  108. $ cd /home/pleroma/pleroma
  109. $ MIX_ENV=prod mix ecto.migrate
  110. ```
  111. ## Configuring nginx
  112. Install the example configuration file
  113. (`$PREFIX/share/examples/pleroma/pleroma.nginx` or `/home/pleroma/pleroma/installation/pleroma.nginx`) to
  114. `$PREFIX/etc/nginx.conf`.
  115. Note that it will need to be wrapped in a `http {}` block. You should add
  116. settings for the nginx daemon outside of the http block, for example:
  117. ```
  118. user nginx nginx;
  119. error_log /var/log/nginx/error.log;
  120. worker_processes 4;
  121. events {
  122. }
  123. ```
  124. Edit the defaults:
  125. * Change `ssl_certificate` and `ssl_trusted_certificate` to
  126. `/etc/nginx/tls/fullchain`.
  127. * Change `ssl_certificate_key` to `/etc/nginx/tls/key`.
  128. * Change `example.tld` to your instance's domain name.
  129. ### (Strongly recommended) serve media on another domain
  130. Refer to the [Hardening your instance](../configuration/hardening.md) document on how to serve media on another domain. We STRONGLY RECOMMEND you to do this to minimize attack vectors.
  131. ## Configuring acme.sh
  132. We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
  133. First, get your account fingerprint:
  134. ```
  135. $ sudo -Hu nginx -g nginx acme.sh --register-account
  136. ```
  137. You need to add the following to your nginx configuration for the server
  138. running on port 80:
  139. ```
  140. location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
  141. default_type text/plain;
  142. return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
  143. }
  144. ```
  145. Replace the string after after `$1.` with your fingerprint.
  146. Start nginx:
  147. ```
  148. # /etc/rc.d/nginx start
  149. ```
  150. It should now be possible to issue a cert (replace `example.com`
  151. with your domain name):
  152. ```
  153. $ sudo -Hu nginx -g nginx acme.sh --issue -d example.com --stateless
  154. ```
  155. Let's add auto-renewal to `/etc/daily.local`
  156. (replace `example.com` with your domain):
  157. ```
  158. /usr/pkg/bin/sudo -Hu nginx -g nginx \
  159. /usr/pkg/sbin/acme.sh -r \
  160. -d example.com \
  161. --cert-file /etc/nginx/tls/cert \
  162. --key-file /etc/nginx/tls/key \
  163. --ca-file /etc/nginx/tls/ca \
  164. --fullchain-file /etc/nginx/tls/fullchain \
  165. --stateless
  166. ```
  167. ## Autostart
  168. For properly functioning instance, you will need pleroma (backend service), nginx (reverse proxy) and postgresql (database) services running. There's no requirement for them to reside on the same machine, but you have to provide autostart for each of them.
  169. ### nginx
  170. ```
  171. # cp $PREFIX/share/examples/rc.d/nginx /etc/rc.d
  172. # echo "nginx=YES" >> /etc/rc.conf
  173. ```
  174. ### postgresql
  175. ```
  176. # cp $PREFIX/share/examples/rc.d/pgsql /etc/rc.d
  177. # echo "pgsql=YES" >> /etc/rc.conf
  178. ```
  179. ### pleroma
  180. First, copy the script (pkgsrc variant)
  181. ```
  182. # cp $PREFIX/share/examples/pleroma/pleroma.rc /etc/rc.d/pleroma
  183. ```
  184. or source variant
  185. ```
  186. # cp /home/pleroma/pleroma/installation/netbsd/rc.d/pleroma /etc/rc.d/pleroma
  187. # chmod +x /etc/rc.d/pleroma
  188. ```
  189. Then, add the following to `/etc/rc.conf`:
  190. ```
  191. pleroma=YES
  192. ```
  193. ## Conclusion
  194. Run `# /etc/rc.d/pleroma start` to start Pleroma.
  195. Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
  196. Make sure your time is in sync, or other instances will receive your posts with
  197. incorrect timestamps. You should have ntpd running.
  198. ## Instances running NetBSD
  199. * <https://catgirl.science>
  200. #### Further reading
  201. {! backend/installation/further_reading.include !}
  202. ## Questions
  203. Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.