{"id":173,"date":"2022-11-13T13:46:22","date_gmt":"2022-11-13T13:46:22","guid":{"rendered":"https:\/\/wordpress.debian.social\/jlines\/?p=173"},"modified":"2022-12-07T13:09:13","modified_gmt":"2022-12-07T13:09:13","slug":"setting-up-a-small-pleroma-server","status":"publish","type":"post","link":"https:\/\/wordpress.debian.social\/jlines\/2022\/11\/13\/setting-up-a-small-pleroma-server\/","title":{"rendered":"Setting up a Small Pleroma Server"},"content":{"rendered":"\n<p><em>This is a work in progress and will be updated as I get time. Initially it simply documented what I did for my own server, but now it reflects a build on a test server. I intend to refine it iteratively.<\/em><\/p>\n\n\n\n<p>My first installation of the Pleroma server social.paladyn.org, was through a <a rel=\"noreferrer noopener\" href=\"https:\/\/yunohost.org\/\" target=\"_blank\">Yunohost<\/a> server, which I had set up on a <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/QEMU\" target=\"_blank\">QEMU<\/a> Virtual Machine, which runs Debian Bullseye. This worked quite well to try, but had several drawbacks, including that it shared the same external IPv4 address with several other systems, which introduced complexities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"WhichSoftware\">Pleroma, Mastodon or what ?<\/h3>\n\n\n\n<p>Mastodon is the best known name in the ActivityPub Federated area, and my first venture into the Fediverse was as <a rel=\"noreferrer noopener\" href=\"https:\/\/mstdn.io\/@JohnLines\" target=\"_blank\">@JohnLines@mstdn.io<\/a> &#8211; but I wanted to understand the platform well enough that I could contribute to making it more widely available &#8211; probably as part of a <a href=\"https:\/\/wordpress.debian.social\/jlines\/2021\/11\/11\/small-organisation-server-the-target\/\" data-type=\"post\" data-id=\"110\" target=\"_blank\" rel=\"noreferrer noopener\">Small Organisation Server<\/a>. <\/p>\n\n\n\n<p>Debian has a <a rel=\"noreferrer noopener\" href=\"https:\/\/wiki.debian.org\/Teams\/DebianSocial\" target=\"_blank\">team<\/a> working on providing Social Networking for Developers, and <a rel=\"noreferrer noopener\" href=\"https:\/\/wiki.debian.org\/FediverseTeam\" target=\"_blank\">another<\/a> working on packaging. Through the Social team I am <a rel=\"noreferrer noopener\" href=\"https:\/\/pleroma.debian.social\/jlines\" target=\"_blank\">@jlines@pleroma.debian.social<\/a> which steered me towards Pleroma, particularly as Pleroma and Mastodon work together.<\/p>\n\n\n\n<p>That working together, but not being Mastodon, is important as for a protocol to be an <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Internet_Engineering_Task_Force\" target=\"_blank\">IETF<\/a> <a href=\"https:\/\/en.wikipedia.org\/wiki\/Internet_Standard\" target=\"_blank\" rel=\"noreferrer noopener\">Standard<\/a> it must have two independent, interoperating implementations. Diversity in implementing the Fediverse makes for a healthier ecosystem.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Yunohost<\/h3>\n\n\n\n<p>Yunohost is an all-in-one solution, which is well worth investigating if you have a system which is not already set up doing other things, but in my case I decided to migrate to running Pleroma directly on a Debian Bullseye system which was already running Nginx, but did not have much running which would conflict with Pleroma.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pleroma from Source<\/h3>\n\n\n\n<p>The <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.pleroma.social\/backend\/installation\/debian_based_en\/\" target=\"_blank\">official Pleroma instructions for install on Debian<\/a> have two methods, one is what they call an <a href=\"https:\/\/docs.pleroma.social\/backend\/installation\/otp_en\/\" target=\"_blank\" rel=\"noreferrer noopener\">OTP release<\/a> &#8211; where they supply a pre-built binary image for many popular computer architectures, the other is to build it from source.<\/p>\n\n\n\n<p>As my end goal is a Debian package, I went down the build from source route. <strong>In the following instructions I have adhered to the Pleroma instructions, rather than Debian standards for file locations etc.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Picking a name and setting up DNS.<\/h3>\n\n\n\n<p>You will need a name for your Federated Social Media System. Although this document is about installing Pleroma you may want to consider a more generic name, for example setting up social.example.com, in the same way as you might use www.example.com, rather than apache.example.com to allow a future switch to nginx, or vice versa. If you set up the name pointing to your target system now then there is more chance for it to propagate before you need it. You will also be asked an admin email address later, and an address for sending email notifications. You may need to do some preparation for these too.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Preparing for the installation.<\/h4>\n\n\n\n<p>In order to make sure the target system knows the dependencies which should be installed I have started a Debian package called pleroma-installer.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">pleroma-installer<\/h4>\n\n\n\n<p>Note that in these commands I have a blank line between each command. They may wrap round when shown in your browser, but should be entered as one line. I have put parts you will need to change for your system in <em>italics<\/em>.<\/p>\n\n\n\n<p>At the moment this simply asks for dependencies, and can be downloaded from <a href=\"https:\/\/paladyn.org\/john\/tmp\/pleroma-installer_0.0.1_all.deb\">https:\/\/paladyn.org\/john\/tmp\/pleroma-installer_0.0.1_all.deb<\/a> &#8211; install it by<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -nc https:\/\/paladyn.org\/john\/tmp\/pleroma-installer_0.0.1_all.deb\n\nsudo apt install  .\/pleroma-installer_0.0.1_all.deb<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>This will install the dependencies, and apt will know that they were installed for a reason, and not try to clean them up.<\/p>\n\n\n\n<p><em>The plan is to create an apt repository for this installer package to enable it to be updated by apt, however as it is an installer, not a real package this is not a high priority.<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create a user and directories<\/h4>\n\n\n\n<p>On installation the package will create a pleroma user and a directory \/opt\/pleroma which is the main place the files are kept. If \/opt\/pleroma exists it will be moved to \/opt\/pleroma.<em>yyyymmddhhmm<\/em> and the pleroma files will be fetched again.<\/p>\n\n\n\n<p>There will be a warning about Federation not working until it is configured.<\/p>\n\n\n\n<p>At present this is as far as the installer package goes, partly as the next section will have some questions to answer.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Generate the instance<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/opt\/pleroma\n\nsudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen <\/code><\/pre>\n\n\n\n<p>Say Y to install rebar3. You will be asked for the name and email addresses you chose above. Otherwise I used the defaults, except for answering &#8216;y&#8217; to Do you want to store the configuration in the database.<\/p>\n\n\n\n<p>The installation should complete, saying &#8216;All files successfully written!&#8217;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hu pleroma mv config\/{generated_config.exs,prod.secret.exs}\n\nsudo -Hu postgres psql -f config\/setup_db.psql\n<\/code><\/pre>\n\n\n\n<p>The above steps put the configuration where pleroma expects it, and do the initial database setup. As I chose the option to store the configuration in the database I did:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hu pleroma MIX_ENV=prod mix ecto.migrate<\/code><\/pre>\n\n\n\n<p>You should see logs about lots of files being compiled.<\/p>\n\n\n\n<p>At this stage pleroma should be installed and ready to run, start it with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hu pleroma MIX_ENV=prod mix phx.server<\/code><\/pre>\n\n\n\n<p>You will end up with pleroma running as a background process.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Set up nginx<\/h4>\n\n\n\n<p>If you started with an empty server then the installer should have pulled nginx, but if you already had apache2 installed then it will not switch web servers on you. I have not tested pleroma behind apache2. but there is a sample apache configuration in \/opt\/pleroma\/installation <\/p>\n\n\n\n<p>Check if nginx is running by<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status nginx<\/code><\/pre>\n\n\n\n<p>and stop it by<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl stop nginx<\/code><\/pre>\n\n\n\n<p>Now install an SSL certificate for your new subdomain &#8211; note that it will need to exist by this stage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot certonly --email <em>myuser@example.org<\/em> -d <em>social.example.org<\/em> --standalone<\/code><\/pre>\n\n\n\n<p>This can fail if some other program is using port 80 (the non SSL secured web port on your computer) &#8211; for example if or apache is running, of if your domain is mistyped, or does not exist yet. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo cp \/opt\/pleroma\/installation\/pleroma.nginx \/etc\/nginx\/sites-available\/pleroma.nginx\n\nsudo ln -s \/etc\/nginx\/sites-available\/pleroma.nginx \/etc\/nginx\/sites-enabled\/pleroma.nginx\n<\/code><\/pre>\n\n\n\n<p>Edit \/etc\/ngix\/sites-available\/pleroma.nginx to change all occurrences of sample.tld to your server name e.g. <em>social.example.com<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo cp \/opt\/pleroma\/installation\/pleroma.service pleroma.service\n\nsudo systemctl enable --now pleroma.service\n<\/code><\/pre>\n\n\n\n<p>You should now be able to access your server at <em>https:\/\/social.example.com\/<\/em> &#8211; check here if this does not work.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create your first user<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <em>myuser<\/em> <em>myuser@example.com<\/em> --admin<\/code><\/pre>\n\n\n\n<p>Part of the output from the pleroma.user command will be a password reset URL &#8211; enter the link into a web browser, set your password and you should have set up a pleroma server !<\/p>\n\n\n\n<p>Feedback on this post is welcome, either by comments on this post (note that they are moderated so will not appear instantly) or via federated social media to <a href=\"https:\/\/pleroma.debian.social\/jlines\" target=\"_blank\" rel=\"noreferrer noopener\">@jlines@pleroma.debian.social<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p>Pleroma has quite a number of pieces, and there are stages where the setup may run into problems. Here are some of the ones which people have encountered, together with what to do about them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"TsCertbot\">Certbot unable to set up the SSL certificate<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"TsHomePage\">Nginx (or apache) showing the home page, not Pleroma<\/h3>\n\n\n\n<p>If you went to the web page of the site you set up, for example https:\/\/social.example.org\/ &#8211; but see a default web page then web server configuration has not taken notice of the new site you added. The first thing to do is restart nginx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart nginx<\/code><\/pre>\n\n\n\n<p>and look again, if you see the home page still then you will need to look further.<\/p>\n\n\n\n<p>The sites which are live can be found in \/etc\/ngnix\/sites-enabled\/ &#8211; as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Symbolic_link\" target=\"_blank\" rel=\"noreferrer noopener\">symbolic links<\/a> to the real configurations. <\/p>\n\n\n\n<p>You can check by<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/etc\/nginx\/sites-enabled<\/code><\/pre>\n\n\n\n<p>You should see a line like<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">lrwxrwxrwx 1 root root 40 Nov 3 18:39 pleroma.nginx -&gt; \/etc\/nginx\/sites-available\/pleroma.nginx<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"TsNoNginx\">Nginx not running<\/h3>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Removing pleroma<\/h2>\n\n\n\n<p>When there is a real Debian package this should just a a matter of<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt remove pleroma<\/code><\/pre>\n\n\n\n<p>but at present it does not have an uninstall script, and what it should do to tidy up is not obvious.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Removing the database<\/h3>\n\n\n\n<p>You might want to do this in order to do a re-install cleanly<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl stop pleroma.service\n\nsudo -Hu postgres psql -c 'DROP DATABASE pleroma; '\n\nsudo -Hu postgres psql -c 'DROP USER pleroma; '\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Removing the files<\/h3>\n\n\n\n<p>All the files are created under \/opt\/pleroma, but if you run the installer a second time it moves \/opt\/pleroma in order to have a clean install, but not lose anything if you want to go back, or compare configuration files.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a work in progress and will be updated as I get time. Initially it simply documented what I did for my own server, but now it reflects a build on a test server. I intend to refine it iteratively. My first installation of the Pleroma server social.paladyn.org, was through a Yunohost server, which &hellip; <a href=\"https:\/\/wordpress.debian.social\/jlines\/2022\/11\/13\/setting-up-a-small-pleroma-server\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up a Small Pleroma Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-173","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/posts\/173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/comments?post=173"}],"version-history":[{"count":17,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/posts\/173\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/posts\/173\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/media?parent=173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/categories?post=173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.debian.social\/jlines\/wp-json\/wp\/v2\/tags?post=173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}