1 # Installing on RedHat using OTP releases
3 ## OTP releases and Fedora/RedHat
5 The current OTP builds available for Linux are unfortunately incompatible with RedHat Linux distributions, like Fedora and Centos Stream. This is due to RedHat maintaining patched versions of certain Erlang libraries, making them incompatible with other Linux distributions.
7 However, you may compile your own OTP release from scratch. This is particularly useful if you wish to quickly distribute your OTP build onto multiple systems, without having to worry about compiling code on every system. However, if your goal is to simply set up a single instance for yourself, installing from-source might be a simpler option. To install from-source, please follow [this guide](./fedora_based_en.md).
12 In order to compile a RedHat-compatible OTP release, you will need to run a RedHat Linux distribution. This guide will assume you run Fedora 36, though it should also work on older Fedora releases and other RedHat distributions. It also assumes that you have administrative rights and sufficient knowledge on how to perform common CLI tasks in Linux. If you want to run this guide with root, ignore the `sudo` at the beginning of the lines.
14 Important: keep in mind that you must build your OTP release for the specific RedHat distribution you wish to use it on. A build on Fedora will only be compatible with a specific Fedora release version.
17 ## Building an OTP release for Fedora 36
19 ### Installing required packages
21 * First, update your system, if not already done:
24 sudo dnf upgrade --refresh
27 * Then install the required packages to build your OTP release:
30 sudo dnf install git gcc g++ erlang elixir erlang-os_mon erlang-eldap erlang-xmerl erlang-erl_interface erlang-syntax_tools make cmake file-devel
34 ### Preparing the project files
36 * Git clone the AkkomaBE repository. This can be done anywhere:
40 git clone https://akkoma.dev/AkkomaGang/akkoma.git -b stable
43 * Change to the new directory:
50 ### Building the OTP release
52 * Run the following commands:
56 echo "import Config" > config/prod.secret.exs
58 mix local.rebar --force
59 mix deps.get --only prod
61 mix release --path release
64 Note that compiling the OTP release will take some time. Once it completes, you will find the OTP files in the directory `release`.
66 If all went well, you will have built your very own Fedora-compatible OTP release! You can now pack up the files in the `release` directory and deploy them to your other Fedora servers.
69 ## Installing the OTP release
71 Installing the OTP release from this point onward will be very similar to the regular OTP release. This guide assumes you will want to install your OTP package on other systems, so additional pre-requisites will be listed below.
73 Please note that running your own OTP release has some minor caveats that you should be aware of. They will be listed below as well.
76 ### Installing required packages
78 Other than things bundled in the OTP release Akkoma depends on:
80 * curl (to download the release build)
81 * ncurses (ERTS won't run without it)
82 * PostgreSQL (also utilizes extensions in postgresql-contrib)
83 * nginx (could be swapped with another reverse proxy but this guide covers only it)
84 * certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
87 First, update your system, if not already done:
90 sudo dnf upgrade --refresh
93 Then install the required packages:
96 sudo dnf install curl ncurses postgresql postgresql-contrib nginx certbot file-devel
100 ### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
102 * Install ffmpeg (requires setting up the RPM-fusion repositories):
105 sudo dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
106 sudo dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
107 sudo dnf install ffmpeg
110 * Install ImageMagick and ExifTool for image manipulation:
113 sudo dnf install Imagemagick perl-Image-ExifTool
117 ### Configuring PostgreSQL
118 #### (Optional) Performance configuration
119 It is encouraged to check [Optimizing your PostgreSQL performance](../configuration/postgresql.md) document, for tips on PostgreSQL tuning.
121 Restart PostgreSQL to apply configuration changes:
124 sudo systemctl restart postgresql
127 ### Installing Akkoma
129 # Create a Akkoma user
130 adduser --system --shell /bin/false --home /opt/akkoma akkoma
132 # Move your custom OTP release to the home directory
133 sudo -Hu akkoma mv /your/custom/otp/release /opt/akkoma
135 # Create uploads directory and set proper permissions (skip if planning to use a remote uploader)
136 # Note: It does not have to be `/var/lib/akkoma/uploads`, the config generator will ask about the upload directory later
138 sudo mkdir -p /var/lib/akkoma/uploads
139 sudo chown -R akkoma /var/lib/akkoma
141 # Create custom public files directory (custom emojis, frontend bundle overrides, robots.txt, etc.)
142 # Note: It does not have to be `/var/lib/akkoma/static`, the config generator will ask about the custom public files directory later
143 sudo mkdir -p /var/lib/akkoma/static
144 sudo chown -R akkoma /var/lib/akkoma
146 # Create a config directory
147 sudo mkdir -p /etc/akkoma
148 sudo chown -R akkoma /etc/akkoma
150 # Run the config generator
151 sudo -Hu akkoma ./bin/pleroma_ctl instance gen --output /etc/akkoma/config.exs --output-psql /tmp/setup_db.psql
153 # Create the postgres database
154 sudo -Hu postgres psql -f /tmp/setup_db.psql
156 # Create the database schema
157 sudo -Hu akkoma ./bin/pleroma_ctl migrate
159 # Start the instance to verify that everything is working as expected
160 sudo -Hu akkoma ./bin/pleroma daemon
162 # Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
163 sleep 20 && curl http://localhost:4000/api/v1/instance
166 sudo -Hu akkoma ./bin/pleroma stop
170 ### Setting up nginx and getting Let's Encrypt SSL certificaties
172 #### Get a Let's Encrypt certificate
175 certbot certonly --standalone --preferred-challenges http -d yourinstance.tld
178 #### Copy Akkoma nginx configuration to the nginx folder
181 cp /opt/akkoma/installation/nginx/akkoma.nginx /etc/nginx/conf.d/akkoma.conf
184 #### Edit the nginx config
186 # Replace example.tld with your (sub)domain (replace $EDITOR with your editor of choice)
187 sudo $EDITOR /etc/nginx/conf.d/akkoma.conf
189 # Verify that the config is valid
195 sudo systemctl start nginx
198 At this point if you open your (sub)domain in a browser you should see a 502 error, that's because Akkoma is not started yet.
201 ### Setting up a system service
204 # Copy the service into a proper directory
205 cp /opt/akkoma/installation/akkoma.service /etc/systemd/system/akkoma.service
207 # Edit the service file and make any neccesary changes
208 sudo $EDITOR /etc/systemd/system/akkoma.service
210 # If you use SELinux, set the correct file context on the pleroma binary
211 sudo semanage fcontext -a -t init_t /opt/akkoma/bin/pleroma
212 sudo restorecon -v /opt/akkoma/bin/pleroma
214 # Start akkoma and enable it on boot
215 sudo systemctl start akkoma
216 sudo systemctl enable akkoma
219 If everything worked, you should see a response from Akkoma-BE when visiting your domain. You may need to install frontends like Akkoma-FE and Admin-FE; refer to [this guide](../administration/CLI_tasks/frontend.md) on how to install them.
221 If that didn't happen, try reviewing the installation steps, starting Akkoma in the foreground and seeing if there are any errrors.
223 {! support.include !}
227 ### Setting up auto-renew of the Let's Encrypt certificate
230 # Create the directory for webroot challenges
231 sudo mkdir -p /var/lib/letsencrypt
233 # Uncomment the webroot method
234 sudo $EDITOR /etc/nginx/conf.d/akkoma.conf
236 # Verify that the config is valid
240 sudo systemctl restart nginx
242 # Ensure the webroot menthod and post hook is working
243 sudo certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'systemctl reload nginx'
245 # Add it to the daily cron
247 certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"
248 ' > /etc/cron.daily/renew-akkoma-cert
249 sudo chmod +x /etc/cron.daily/renew-akkoma-cert
251 # If everything worked the output should contain /etc/cron.daily/renew-akkoma-cert
252 sudo run-parts --test /etc/cron.daily
256 ## Create your first user and set as admin
259 sudo -Hu akkoma ./bin/pleroma_ctl user new joeuser joeuser@sld.tld --admin
261 This will create an account withe the username of 'joeuser' with the email address of joeuser@sld.tld, and set that user's account as an admin. This will result in a link that you can paste into the browser, which logs you in and enables you to set the password.
265 ### Caveats of building your own OTP release
267 There are some things to take note of when your are running your own OTP builds.
269 #### Updating your OTP builds
271 Using your custom OTP build, you will not be able to update the installation using the `pleroma_ctl update` command. Running this command would overwrite your install with an OTP release from the main Akkoma repository, which will break your install.
273 Instead, you will have to rebuild your OTP release every time there are updates, then manually move it to where your Akkoma installation is running, overwriting the old OTP release files. Make sure to stop the Akkoma-BE server before overwriting any files!
275 After that, run the `pleroma_ctl migrate` command as usual to perform database migrations.
278 #### Cross-compatibility between RedHat distributions
280 As it currently stands, your OTP build will only be compatible for the specific RedHat distribution you've built it on. Fedora builds only work on Fedora, Centos builds only on Centos, RedHat builds only on RedHat. Secondly, for Fedora, they will also be bound to the specific Fedora release. This is because different releases of Fedora may have significant changes made in some of the required packages and libraries.
282 {! installation/frontends.include !}
284 {! installation/further_reading.include !}
286 {! support.include !}