logo

pleroma

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

freebsd_en.md (6271B)


  1. # Installing on FreeBSD
  2. This document was written for FreeBSD 12.1, but should be work on future releases.
  3. {! backend/installation/generic_dependencies.include !}
  4. ## Installing software used in this guide
  5. This assumes the target system has `pkg(8)`.
  6. ```
  7. # pkg install elixir postgresql12-server postgresql12-client postgresql12-contrib git-lite sudo nginx gmake acme.sh cmake vips
  8. ```
  9. Copy the rc.d scripts to the right directory:
  10. Setup the required services to automatically start at boot, using `sysrc(8)`.
  11. ```
  12. # sysrc nginx_enable=YES
  13. # sysrc postgresql_enable=YES
  14. ```
  15. ## Initialize postgres
  16. ```
  17. # service postgresql initdb
  18. # service postgresql start
  19. ```
  20. ### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md))
  21. ```shell
  22. # pkg install imagemagick ffmpeg p5-Image-ExifTool vips
  23. ```
  24. ## Configuring Pleroma
  25. Create a user for Pleroma:
  26. ```
  27. # pw add user pleroma -m
  28. # echo 'export LC_ALL="en_US.UTF-8"' >> /home/pleroma/.profile
  29. # echo 'export VIX_COMPILATION_MODE=PLATFORM_PROVIDED_LIBVIPS' >> /home/pleroma/.profile
  30. # su -l pleroma
  31. ```
  32. Clone the repository:
  33. ```
  34. $ cd $HOME # Should be the same as /home/pleroma
  35. $ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
  36. ```
  37. Configure Pleroma. Note that you need a domain name at this point:
  38. ```
  39. $ cd /home/pleroma/pleroma
  40. $ mix deps.get # Enter "y" when asked to install Hex
  41. $ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
  42. $ cp config/generated_config.exs config/prod.secret.exs
  43. ```
  44. Since Postgres is configured, we can now initialize the database. There should
  45. now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
  46. *change the password* to a password of your choice. Make sure it is secure, since
  47. it'll be protecting your database. As root, you can now initialize the database:
  48. ```
  49. # cd /home/pleroma/pleroma
  50. # sudo -Hu postgres -g postgres psql -f config/setup_db.psql
  51. ```
  52. Postgres allows connections from all users without a password by default. To
  53. fix this, edit `/var/db/postgres/data12/pg_hba.conf`. Change every `trust` to
  54. `password`.
  55. Once this is done, restart Postgres with:
  56. ```
  57. # service postgresql restart
  58. ```
  59. Run the database migrations.
  60. Back as the pleroma user, run the following to implement any database migrations.
  61. ```
  62. # su -l pleroma
  63. $ cd /home/pleroma/pleroma
  64. $ MIX_ENV=prod mix ecto.migrate
  65. ```
  66. You will need to do this whenever you update with `git pull`:
  67. ## Configuring acme.sh
  68. We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
  69. First, as root, allow the user `acme` to have access to the acme log file, as follows:
  70. ```
  71. # touch /var/log/acme.sh.log
  72. # chown acme:acme /var/log/acme.sh.log
  73. # chmod 600 /var/log/acme.sh.log
  74. ```
  75. Next, obtain your account fingerprint:
  76. ```
  77. # sudo -Hu acme -g acme acme.sh --register-account
  78. ```
  79. You need to add the following to your nginx configuration for the server
  80. running on port 80:
  81. ```
  82. location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
  83. default_type text/plain;
  84. return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
  85. }
  86. ```
  87. Replace the string after after `$1.` with your fingerprint.
  88. Start nginx:
  89. ```
  90. # service nginx start
  91. ```
  92. It should now be possible to issue a cert (replace `example.com`
  93. with your domain name):
  94. ```
  95. # sudo -Hu acme -g acme acme.sh --issue -d example.com --stateless
  96. ```
  97. Let's add auto-renewal to `/etc/crontab`
  98. (replace `example.com` with your domain):
  99. ```
  100. /usr/local/bin/sudo -Hu acme -g acme /usr/local/sbin/acme.sh -r -d example.com --stateless
  101. ```
  102. ### Configuring nginx
  103. FreeBSD's default nginx configuration does not contain an include directive, which is
  104. typically used for multiple sites. Therefore, you will need to first create the required
  105. directory as follows:
  106. ```
  107. # mkdir -p /usr/local/etc/nginx/sites-available
  108. ```
  109. Next, add an `include` directive to `/usr/local/etc/nginx/nginx.conf`, within the `http {}`
  110. block, as follows:
  111. ```
  112. http {
  113. ...
  114. include /usr/local/etc/nginx/sites-available/*;
  115. }
  116. ```
  117. As root, copy `/home/pleroma/pleroma/installation/pleroma.nginx` to
  118. `/usr/local/etc/nginx/sites-available/pleroma.nginx`.
  119. Edit the defaults of `/usr/local/etc/nginx/sites-available/pleroma.nginx`:
  120. * Change `ssl_trusted_certificate` to `/var/db/acme/certs/example.tld/example.tld.cer`.
  121. * Change `ssl_certificate` to `/var/db/acme/certs/example.tld/fullchain.cer`.
  122. * Change `ssl_certificate_key` to `/var/db/acme/certs/example.tld/example.tld.key`.
  123. * Change all references of `example.tld` to your instance's domain name.
  124. #### (Strongly recommended) serve media on another domain
  125. 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.
  126. ## Creating a startup script for Pleroma
  127. Pleroma will need to compile when it initially starts, which typically takes a longer
  128. period of time. Therefore, it is good practice to initially run pleroma from the
  129. command-line before utilizing the rc.d script. That is done as follows:
  130. ```
  131. # su -l pleroma
  132. $ cd $HOME/pleroma
  133. $ MIX_ENV=prod mix phx.server
  134. ```
  135. Copy the startup script to the correct location and make sure it's executable:
  136. ```
  137. # cp /home/pleroma/pleroma/installation/freebsd/rc.d/pleroma /usr/local/etc/rc.d/pleroma
  138. # chmod +x /usr/local/etc/rc.d/pleroma
  139. ```
  140. Update the `/etc/rc.conf` and start pleroma with the following commands:
  141. ```
  142. # sysrc pleroma_enable=YES
  143. # service pleroma start
  144. ```
  145. #### Create your first user
  146. If your instance is up and running, you can create your first user with administrative rights with the following task:
  147. ```shell
  148. sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
  149. ```
  150. ## Conclusion
  151. Restart nginx with `# service nginx restart` and you should be up and running.
  152. Make sure your time is in sync, or other instances will receive your posts with
  153. incorrect timestamps. You should have ntpd running.
  154. ## Questions
  155. 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.