Introduction: I have tried three times to set up a Mastodon server and failed. Despite abandoning this project, I thought I would do a write up since some people might benefit from my failure.
Background: during the recent commotion with Twitter, there was a general movement of people to Mastodon. During this movement, a number of people said they didn’t have a Mastodon server to move to. I didn’t either. When I read that Dan Sinker built his own, I thought I’d try that too. I’ve built many servers on multiple cloud environments and installed complex software in these environments. I figured it was doable.
Documentation: I had two main sources of documentation to help me do this:
– Doc 1: docs.joinmastodon.org/admin/install/
– Doc 2 gist.github.com/johnspurlockskymethod/da09c82e2ed8fabd5f5e164d942ce37c
Doc 1 is the official Mastodon documentation on how to build your own server. Doc 2 is a guide to installing a minimal Mastodon server on Amazon EC2.
Attempt #1: I followed Doc 2 since I was building it on an EC2 instance. I did not do the AWS pre-reqs advised other than create the security groups since I was using Mailgun for smtp and my domain was elsewhere at namecheap.
I did launch an minimal Ubuntu 22.x server that was a t2.micro, I think (1 vCPU, 1 GiB of memory). It was in the free tier. I did create a swap disk.
I ran into a number of problems during this install. Some of the problems I ran into had to do with versions of the software that were backlevelled compared to doc 1 (e.g. Ruby). Also I found that I could not even get the server to start, likely because there just is not enough memory, even with the swap space. I should have entered “sudo -I” from the start, rather than putting sudo in from of the commands. Doing that in future attempts made things easier. Finally, I deleted the EC2 instance.
Attempt #2: I decided to do a clean install on a new instance. I launched a new EC2 instance than was not free and had 2 vCPU and 2 GiB of memory. I also used doc 1 and referred to doc 2 as a guide. This time I got further. Part of the Mastodon server came up, but I did not get the entire interface. When I checked the server logs (using: journalctl -xf -u mastodon-*) I could see error messages, but despite searching for them, I couldn’t see anything conclusive. I deleted this EC2 instance also.
Attempt #3: I wanted to see if my problems in the previous attempts were due to capacity limitations. I created a third EC2 instance that had 4 vCPU and 8 GiB of memory. This installation went fast and clean. However despite that, I had the same type of errors as the second attempt. At this point I deleted this third instance and quit.
Possible causes of the problem(s) and ways to determine that and resolve them:
– Attempt the installation process on a VM/instance on another cloud provider (Google Cloud, Azure, IBM Cloud). If the problem resolves, the cause could be something to do with AWS.
– Attempt this on a server running Ubuntu 20.04 or Debian 11, either on the cloud or a physical machine. If this resolves, it could be a problem with the version of Ubuntu I was running (22.x): that was the only image available to me on AWS.
– Attempt it using the Docker image version, either on my desktop or in the cloud.
– Attempt to run it on a much bigger instance. Perhaps even a 4 x 8 machine is not sufficient.
– See if the problem is due to my domain being hosted elsewhere in combination with an elastic IP address by trying to use a domain hosted on AWS.
Summary: There are other things I could do to resolve my problems and get the server to work, but in terms of economics: the Law of Diminishing Returns has set in, there are opportunity costs to consider, the sunk costs are what they are, and the marginal utility remaining for me is 0. I learned a lot from this, but even if I got it working, I don’t want to run a Mastodon server long term, nor do I want to pay AWS for the privilege. Furthermore, I don’t want to spend time learning more about Ruby, which I think is where the problem may originate. It’s time for me to spend my precious time on technologies that are personally and professionally better rewarding.
Lessons Learned: What did I learned from this?
– Mastodon is a complicated beast. Anyone installing it must have an excellent understanding of Linux/Unix. If you want to install it on AWS for free, you really must be knowledgeable. Not only that, it consists of not only its own software, but nginx, Postgres, Redis and Ruby. Plus you need to be comfortable setting up SSL. If everything goes according to the doc, you are golden. If not, you really need an array of deep skills to solve any issues you have.
– Stick with the official documentation when it comes to installing Mastodon. Most of the many other pages I reviewed were out of date or glossed over things of note.
– Have all the information you need at hand. I did not have my Mailgun information available for the first attempt. Having it available for the second attempt helped.
– The certbot process in the official document did not work for me. I did this instead:
1) systemctl stop nginx.service
2) certbot certonly –standalone -d example.com (I used my own domain and my personal email and replied Y to other prompts.)
3) systemctl restart nginx.service
– Make sure you have port 80 open: you need it for certbot. I did not initially for attempt 3 and that caused me problems. I needed to adjust my security group. (Hey, there are a lot of steps: you too will likely mess up on one or two. :))
– As I mentioned earlier, go from the beginning with: sudo -i
– Make sure the domain you set up points to your EC2 instance. Mine did not initially.
Finally: good luck with your installation. I hope it goes well.
P.S. In the past I would have persevered, because like a lot of technical people, I think: what will people think of me if I can’t get this to work?? Maybe they think I am no good??? 🙂 It seems silly, but plenty of technical people are motivated that way. I am still somewhat motivated that way. But pouring more time in this is like pouring more money into an old car you know you should just give up on vs continuing to try and fix.
P.S.S. Here’s a bunch of Mastodon links that you may find helpful: