logo

pleroma

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

openbsd_en.md (11695B)


  1. # Installing on OpenBSD
  2. {! backend/installation/otp_vs_from_source_source.include !}
  3. This guide describes the installation and configuration of Pleroma (and the required software to run it) on a single OpenBSD 7.7 server.
  4. For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
  5. {! backend/installation/generic_dependencies.include !}
  6. ## Installation
  7. ### Preparing the system
  8. #### Required software
  9. To install required packages, run the following command:
  10. ```
  11. # pkg_add elixir gmake git postgresql-server postgresql-contrib cmake libmagic libvips
  12. ```
  13. Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd).
  14. Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
  15. #### Optional software
  16. * ImageMagick
  17. * ffmpeg
  18. * exiftool
  19. To install the above:
  20. ```
  21. # pkg_add ImageMagick ffmpeg p5-Image-ExifTool
  22. ```
  23. For more information read [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md):
  24. ### PostgreSQL
  25. Switch to the \_postgresql user and initialize PostgreSQL:
  26. ```
  27. # su _postgresql
  28. $ initdb -D /var/postgresql/data -U postgres --encoding=utf-8 --lc-collate=C
  29. ```
  30. Running PostgreSQL in a different directory than `/var/postgresql/data` requires changing the `daemon_flags` variable in the `/etc/rc.d/postgresql` script.
  31. For security reasons it is recommended to change the authentication method for `local` and `host` connections with the localhost address to `scram-sha-256`.<br>
  32. Do not forget to set a password for the `postgres` user before doing so, otherwise you won't be able to log back in unless you change the authentication method back to `trust`.<br>
  33. Changing the password hashing algorithm is not needed.<br>
  34. For more information [read](https://www.postgresql.org/docs/16/auth-pg-hba-conf.html) the PostgreSQL documentation.
  35. Enable and start the postgresql service:
  36. ```
  37. # rcctl enable postgresql
  38. # rcctl start postgresql
  39. ```
  40. To check that PostgreSQL started properly and didn't fail right after starting, run `# rcctl check postgresql` which should return `postgresql(ok)`.
  41. ### Configuring Pleroma
  42. Pleroma will be run by a dedicated \_pleroma user. Before creating it, insert the following lines in `/etc/login.conf`:
  43. ```
  44. pleroma:\
  45. :datasize=1536M:\
  46. :openfiles-max=4096:\
  47. :openfiles-cur=1024:\
  48. :setenv=LC_ALL=en_US.UTF-8,VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPS,MIX_ENV=prod:\
  49. :tc=daemon:
  50. ```
  51. This creates a "pleroma" login class and sets higher values than default for datasize and openfiles (see [login.conf(5)](https://man.openbsd.org/login.conf)), this is required to avoid having Pleroma crash some time after starting.
  52. Create the \_pleroma user, assign it the pleroma login class and create its home directory (/home/\_pleroma/):
  53. ```
  54. # useradd -m -L pleroma _pleroma
  55. ```
  56. Switch to the _pleroma user:
  57. ```
  58. # su -l _pleroma
  59. ```
  60. Clone the Pleroma repository:
  61. ```
  62. $ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
  63. $ cd pleroma
  64. ```
  65. Pleroma is now installed in /home/\_pleroma/pleroma/. To configure it run:
  66. ```
  67. $ mix deps.get
  68. $ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
  69. $ cp config/generated_config.exs config/prod.secret.exs
  70. ```
  71. Note: Answer yes when asked to install Hex and rebar3. This step might take some time as Pleroma gets compiled first.
  72. Create the Pleroma database:
  73. ```
  74. $ psql -U postgres -f config/setup_db.psql
  75. ```
  76. Apply database migrations:
  77. ```
  78. $ MIX_ENV=prod mix ecto.migrate
  79. ```
  80. Note: You will need to run this step again when updating your instance to a newer version with `git pull` or `git checkout tags/NEW_VERSION`.
  81. As \_pleroma in /home/\_pleroma/pleroma, you can now run `MIX_ENV=prod mix phx.server` to start your instance.
  82. In another SSH session or a tmux window, check that it is working properly by running `ftp -MVo - http://127.0.0.1:4000/api/v1/instance`, you should get json output.
  83. Double-check that the *uri* value near the bottom is your instance's domain name and the instance *title* are correct.
  84. ### Configuring acme-client
  85. acme-client is used to get SSL/TLS certificates from Let's Encrypt.
  86. Insert the following configuration in `/etc/acme-client.conf` and replace `example.tld` with your domain:
  87. ```
  88. #
  89. # $OpenBSD: acme-client.conf,v 1.5 2023/05/10 07:34:57 tb Exp $
  90. #
  91. authority letsencrypt {
  92. api url "https://acme-v02.api.letsencrypt.org/directory"
  93. account key "/etc/acme/letsencrypt-privkey.pem"
  94. }
  95. domain example.tld {
  96. # Adds alternative names to the certificate. Useful when serving media on another domain. Comma or space separated list.
  97. # alternative names { }
  98. domain key "/etc/ssl/private/example.tld.key"
  99. domain certificate "/etc/ssl/example.tld_cert-only.crt"
  100. domain full chain certificate "/etc/ssl/example.tld.crt"
  101. sign with letsencrypt
  102. }
  103. ```
  104. Check the configuration:
  105. ```
  106. # acme-client -n
  107. ```
  108. ### Configuring the Web server
  109. Pleroma supports two Web servers:
  110. * nginx (recommended for most users)
  111. * OpenBSD's httpd and relayd (ONLY for advanced users, media proxy cache is NOT supported and will NOT work properly)
  112. #### nginx
  113. Since nginx is not installed by default, install it by running:
  114. ```
  115. # pkg_add nginx
  116. ```
  117. Add the following to `/etc/nginx/nginx.conf`, within the `server {}` block listening on port 80 and change `server_name`, as follows:
  118. ```
  119. http {
  120. ...
  121. server {
  122. ...
  123. server_name localhost; # Replace with your domain
  124. location /.well-known/acme-challenge {
  125. rewrite ^/\.well-known/acme-challenge/(.*) /$1 break;
  126. root /var/www/acme;
  127. }
  128. }
  129. }
  130. ```
  131. Start the nginx service and acquire certificates:
  132. ```
  133. # rcctl start nginx
  134. # acme-client example.tld
  135. ```
  136. Add certificate auto-renewal by adding acme-client to `/etc/weekly.local`, replace `example.tld` with your domain:
  137. ```
  138. # echo "acme-client example.tld && rcctl reload nginx" >> /etc/weekly.local
  139. ```
  140. OpenBSD's default nginx configuration does not contain an include directive, which is typically used for multiple sites.
  141. Therefore, you will need to first create the required directory as follows:
  142. ```
  143. # mkdir /etc/nginx/sites-available
  144. # mkdir /etc/nginx/sites-enabled
  145. ```
  146. Next add the `include` directive to `/etc/nginx/nginx.conf`, within the `http {}` block, as follows:
  147. ```
  148. http {
  149. ...
  150. server {
  151. ...
  152. }
  153. include /etc/nginx/sites-enabled/*;
  154. }
  155. ```
  156. As root, copy `/home/_pleroma/pleroma/installation/pleroma.nginx` to `/etc/nginx/sites-available/pleroma.nginx`.
  157. Edit default `/etc/nginx/sites-available/pleroma.nginx` settings and replace `example.tld` with your domain:
  158. * Uncomment the location block for `~ /\.well-known/acme-challenge` in the server block listening on port 80
  159. - add `rewrite ^/\.well-known/acme-challenge/(.*) /$1 break;` above the `root` location
  160. - change the `root` location to `/var/www/acme;`
  161. * Change `ssl_trusted_certificate` to `/etc/ssl/example.tld_cert-only.crt`
  162. * Change `ssl_certificate` to `/etc/ssl/example.tld.crt`
  163. * Change `ssl_certificate_key` to `/etc/ssl/private/example.tld.key`
  164. Remove the following `location {}` block from `/etc/nginx/nginx.conf`, that was previously added for acquiring certificates and change `server_name` back to `localhost`:
  165. ```
  166. http {
  167. ...
  168. server {
  169. ...
  170. server_name example.tld; # Change back to localhost
  171. # Delete this block
  172. location /.well-known/acme-challenge {
  173. rewrite ^/\.well-known/acme-challenge/(.*) /$1 break;
  174. root /var/www/acme;
  175. }
  176. }
  177. }
  178. ```
  179. Symlink the Pleroma configuration to the enabled sites:
  180. ```
  181. # ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled
  182. ```
  183. Check nginx configuration syntax by running:
  184. ```
  185. # nginx -t
  186. ```
  187. Note: If the above command complains about a `conflicting server name`, check again that the `location {}` block for acquiring certificates has been removed from `/etc/nginx/nginx.conf` and that the `server_name` has been reverted back to `localhost`.
  188. After doing so run `# nginx -t` again.
  189. If the configuration is correct, you can now enable and reload the nginx service:
  190. ```
  191. # rcctl enable nginx
  192. # rcctl reload nginx
  193. ```
  194. #### httpd
  195. ***Skip this section when using nginx***
  196. httpd will have two functions:
  197. * redirect requests trying to reach the instance over http to the https URL
  198. * get Let's Encrypt certificates, with acme-client
  199. As root, copy `/home/_pleroma/pleroma/installation/openbsd/httpd.conf` to `/etc/httpd.conf`, or modify the existing one.
  200. Edit `/etc/httpd.conf` settings and change:
  201. * `<ipaddr>` with your instance's IPv4 address
  202. * All occurrences of `example.tld` with your instance's domain name
  203. * When using IPv6 also change:
  204. - Uncomment the `ext_inet6="<ip6addr>"` line near the beginning of the file and change `<ip6addr` to your instance's IPv6 address
  205. - Uncomment the line starting with `listen on $ext_inet6` in the `server` block
  206. Check the configuration by running:
  207. ```
  208. # httpd -n
  209. ```
  210. If the configuration is correct, enable and start the `httpd` service:
  211. ```
  212. # rcctl enable httpd
  213. # rcctl start httpd
  214. ```
  215. Acquire certificate:
  216. ```
  217. # acme-client example.tld
  218. ```
  219. #### relayd
  220. ***Skip this section when using nginx***
  221. relayd will be used as the reverse proxy sitting in front of pleroma.
  222. As root, copy `/home/_pleroma/pleroma/installation/openbsd/relayd.conf` to `/etc/relayd.conf`, or modify the existing one.
  223. Edit `/etc/relayd.conf` settings and change:
  224. * `<ipaddr>` with your instance's IPv4 address
  225. * All occurrences of `example.tld` with your instance's domain name
  226. * When using IPv6 also change:
  227. - Uncomment the `ext_inet6="<ip6addr>"` line near the beginning of the file and change `<ip6addr>` to your instance's IPv6 address
  228. - Uncomment the line starting with `listen on $ext_inet6` in the `relay wwwtls` block
  229. Check the configuration by running:
  230. ```
  231. # relayd -n
  232. ```
  233. If the configuration is correct, enable and start the `relayd` service:
  234. ```
  235. # rcctl enable relayd
  236. # rcctl start relayd
  237. ```
  238. Add certificate auto-renewal by adding acme-client to `/etc/weekly.local`, replace `example.tld` with your domain:
  239. ```
  240. # echo "acme-client example.tld && rcctl reload relayd" >> /etc/weekly.local
  241. ```
  242. #### (Strongly recommended) serve media on another domain
  243. 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.
  244. ### Starting pleroma at boot
  245. Copy the startup script and make sure it's executable:
  246. ```
  247. # cp /home/_pleroma/pleroma/installation/openbsd/rc.d/pleroma /etc/rc.d/pleroma
  248. # chmod 555 /etc/rc.d/pleroma
  249. ```
  250. Enable and start the pleroma service:
  251. ```
  252. # rcctl enable pleroma
  253. # rcctl start pleroma
  254. ```
  255. ### Create administrative user
  256. If your instance is up and running, you can create your first user with administrative rights with the following commands as the \_pleroma user:
  257. ```
  258. $ cd pleroma
  259. $ MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
  260. ```
  261. ### Further reading
  262. {! backend/installation/further_reading.include !}
  263. ## Questions
  264. 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.