29
submitted 1 year ago by [email protected] to c/[email protected]

This weekend I installed my own Lemmy instance, so I want to share the instructions to help others, who want to do the same.

I used the Ansible script and it was pretty easy. First I wanted to use my existing PosgreSQL server, what I already use for my Akkoma server. It didn't really work out that well, the migrations failed and I couldn't figure out what didn't work. Eventually I just went back using PostgreSQL on Docker. If you don't start modifying the script, and just use the dockerized PostgreSQL, you will have no problems with the installation.

What you need first is a cheap (or expensive, if you decide to invite million friends to your instance) VPS: I use Hetzner Cloud, which has been working for me super well for many years and I'm very happy with the service. I got the second cheapest AMD instance, with two cores and two gigabytes of RAM. Before buying the instance, you need to upload an SSH key to Hetzner. If you don't have one, creating is easy from the command line: ssh-keygen -t ecdsa. What you need to give to Hetzner is your public key; the one with the .pub extension in your $HOME/.ssh directory. Do not give the private key to anyone. Go with Ubuntu, might work the best with the Ansible script.

You can now SSH to the instance: ssh root@<ip-address from the Hetzner control panel>.

Next what you need is a domain name for the server. Lemmy wants an A record, and being a good internet citizen, you also get an AAAA record for the IPv6 users. I use Cloudflare for my DNS records. It's very easy to set them from their control panel. Do not set the proxy on just yet, we'll come back to that later. You can get the IP addresses from the Hetzner panel. The IPv4 you just copy, for the IPv6 you have to replace the ::/64 with ::1.

Now you should be able to ssh to your instance with the new domain name. It's time to follow the Ansible instructions for Lemmy, just run the script and see it's done correctly with no errors. When you can login to your Lemmy instance as an admin, go back to Cloudflare and turn on proxying to your A and AAAA records to hide your server IP and prevent DDOS attacks.

The first time federation is a bit slow in the beginning. Go to search in your instance, and search for [email protected]. It takes a while for the result to arrive. You can SSH to your instance, and look for the logs of your Lemmy image:

root@lemmy:~# docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED        STATUS        PORTS                                NAMES
9e940b84cc45   dessalines/lemmy-ui:0.17.3   "docker-entrypoint.s…"   22 hours ago   Up 22 hours   127.0.0.1:6719->1234/tcp             lemmynaukio_lemmy-ui_1
6442d9d93554   dessalines/lemmy:0.17.3      "/app/lemmy"             22 hours ago   Up 22 hours   127.0.0.1:20926->8536/tcp            lemmynaukio_lemmy_1
36a030f7bf27   asonix/pictrs:0.3.1          "/sbin/tini -- /usr/…"   22 hours ago   Up 22 hours   6669/tcp, 127.0.0.1:8934->8080/tcp   lemmynaukio_pictrs_1
979be89076b2   postgres:15-alpine           "docker-entrypoint.s…"   22 hours ago   Up 22 hours   5432/tcp                             lemmynaukio_postgres_1
774112d48c87   mwader/postfix-relay         "/root/run"              23 hours ago   Up 23 hours   25/tcp                               lemmynaukio_postfix_1
> docker logs -f 6442d9d93554

This should start showing you the federated posts in real time. Eventually your search will show up, you can click the community open and subscribe to it. Do the same for other communities what you want to follow, federate other instances and eventually you are part of the federation. It gets faster and easier for the other users, but the beginning is a bit slow.

Congratulations, you're now a Lemmy admin and part of the bigger federation.

top 31 comments
sorted by: hot top controversial new old
[-] [email protected] 3 points 1 year ago

Thanks for the post! Been thinking of spinning my own instance as well because my Hetzner server doesn't get used that much. Though then I would have to actually make sure it stays up and that I won't just dip out one day lol.

[-] [email protected] 3 points 1 year ago

If you have the talent to run a server somewhere, do it for your friends and get people to the Lemmy ecosystem.

[-] [email protected] 3 points 1 year ago

I used docker-compose version and had to work around a couple of bugs like needing to redundantly install Nginx and Let's Encrypt for it to work properly with SSL and also having to add the lemmy container to the internet facing network due to the DNS not working on it and subsequently loosing federation capability. Overall a bit of a struggle, but this is common with FOSS.

[-] [email protected] 1 points 1 year ago

If you follow all from your instance, you should see all the communities from the servers you federate with.

[-] [email protected] 1 points 1 year ago

Is there a way to tell it to use an existing nginx instance? I run nginx proxy manager for all my stuff and can’t forward 80/443 twice.

[-] [email protected] 2 points 1 year ago

Well if you are using docker-compose you could probably get rid of the nginx container and only deploy the other four: lemmy, lemmy-ui, pictrs, postgres. You would then use the nginx.conf stuff you have in place for the docker container of nginx to proxy to lemmy-ui and lemmy on ports 1234 and 8536. Or if you plan to keep using the docker container for nginx then you can change the listening port in the nginx.conf of the container:

listen 80;

to something different like

listen 1080;

Also in the docker-compose.yml you would update the nginx ports to 1080:1080.

Hope this answers your question.

[-] [email protected] 1 points 1 year ago

Thanks! I’m new to docker-compose (been spoiled by unRAID’s community apps) but will give this a shot.

[-] [email protected] 2 points 1 year ago

No problem, if you run into issues let me know I may be able to help. Not an expert at Docker, but I do have a handful of containers running here and there.

[-] [email protected] 1 points 1 year ago
[-] [email protected] 2 points 1 year ago

How does it compare when hosting own instance. I have dedicated server and probably going to spin up instance just for me and friends.

[-] [email protected] 1 points 1 year ago

Skip the Ansible and install the Docker containers by yourself. Something Lemmy should document a bit better is what version and what extensions of PostgreSQL it needs. If you have an existing server, some of the migrations might fail. Their docker image is using PostgreSQL version 15, so I think that is a safe bet to start.

[-] [email protected] 1 points 1 year ago

And even better, if using NixOS, there's already a recipe for Lemmy: https://nixos.wiki/wiki/Lemmy

[-] [email protected] 2 points 1 year ago

Thank you for the write up! Looks like a simple thing to do!

[-] [email protected] 1 points 1 year ago

The first time federation is a bit slow in the beginning.

Since I don't know any better place to ask and I also setup my instance on Hetzner maybe some of you could provide me with some input regarding federation. I'm able to search new communities; the way I'm doing it right now is by searching for their handler (this !comunnityName@InstanceName thing) on my instance. For some reason if I haven't searched for the community before no search results show up but I can switch to the community all list and see the community there. After subscribing to a community everything works nicely, I see posts, comments everything. But my main question is, if there is a way to federate a server (e.g. lemmy.ml) in a way that I can just click on communities on my server and see every community on the federated servers without having to manually search them first?

This is something that I wasn't able to grasp from reading the lemmy docs and also didn't found a satisfying answer to when googleing.

[-] [email protected] 1 points 1 year ago

Thanks for this. I did the same yesterday on DigitalOcean, but I might migrate to my bigger Hetzner instance if I get enough signups.

A question on searching for communities though:

When I search for a community on another instance to add, I search for [email protected] and nothing shows up, but when I reload the communities window and go to "all" the community shows up to subscribe to.

Do you see the community first time, or is it the same for you as above?

[-] [email protected] 2 points 1 year ago

I sometimes have to do that, switch between all and local, and sometimes just wait a few seconds and it shows up. It's some background process and the user interface doesn't show anything so it can be confusing.

[-] [email protected] 1 points 1 year ago

OK thanks, good to know it's not just me. I'm sure it'll get better now we're gaining more momentum with Lemmy.

[-] [email protected] 1 points 1 year ago

Yep. When you follow the logs, there's lots of action after searching for communities and after subscribing.

[-] [email protected] 1 points 1 year ago

Hey, have you managed to get emails working? Hetzner blocks port 25 and i cannot for the life of me figure out how to get emails to send using any of the external services.

[-] [email protected] 3 points 1 year ago* (last edited 1 year ago)

It was easy. Just look up what smtp server you want to use. I'm on fastmail so I just followed these instructions:

https://www.fastmail.help/hc/en-us/articles/1500000279921-IMAP-POP-and-SMTP

I used smtp with starttls and configured that in the Lemmy hjson config file.

Port 25 is not used because you don't want to send your mail unencrypted over the internet.

[-] [email protected] 1 points 1 year ago

Thanks, i don't want to unblock port 25 particularly, i've been trying to use port 587 with no luck (I get an error about connections). Not sure if the issue is with my postfix relay or with my lemmy hjson file. No matter what i try to change, i can't seem to get a connection to work.

I'll keep trying :)

[-] phase_change 1 points 1 year ago

I played a bit with trying to get a lemmy instance set up on my xcp-ng instance in the home lab. This is the first time I’ve ever touched docker, and email was where I failed. I’ve got a working mail server, but I couldn’t figure out how to get docker to talk to it. Any pointers for some howto in that piece for someone who’s pretty technical but new to docker?

[-] [email protected] 2 points 1 year ago

If you send a ticket to them in the cloud console, they will also unblock port 25

[-] [email protected] 1 points 1 year ago

By default they block ports 25 and 465 afaik you can request getting them unblocked after you paid your first invoice and your account is at least one month old. For some reason they aren't blocking port 587 so you could connect to your mail server via that port if you don't want to wait for the first month to be over using starttls and after a month switch to 465 with normal tls. And as @[email protected] already mentioned you shouldn't use port 25 since you'd be sending your mails unencrypted.

[-] [email protected] 1 points 1 year ago

I did exactly this a week ago to set up my instance but I opted for abit more power, 3 cpus and 4 gb memory. I figured 10 bucks is not very expensive. :)

[-] [email protected] 1 points 1 year ago

I already spend about 40 bucks a month for my instances, so wanted to save money a bit. I have more CPUs for Akkoma due to it using a bit more resources than Lemmy.

[-] [email protected] 1 points 1 year ago
[-] [email protected] 1 points 1 year ago

I just went with the 40GB disk that came with the machine. If you upload a lot of stuff, you might want to use an object storage with the included pictrs setup. A good and cheap solution is Cloudflare R2, that should cost nothing for a small Lemmy server, and is quite cheap still if you upload tens of gigabytes of stuff.

Read more how to use the object storage from the pictrs repo.

Another option if the disk gets full is to mount a volume from Hetzner, and use that volume for pictrs or the database. I doubt you need that though.

load more comments
view more: next ›
this post was submitted on 11 Jun 2023
29 points (100.0% liked)

Self Hosted - Self-hosting your services.

10933 readers
1 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules

Important

Beginning of January 1st 2024 this rule WILL be enforced. Posts that are not tagged will be warned and if not fixed within 24h then removed!

Cross-posting

If you see a rule-breaker please DM the mods!

founded 3 years ago
MODERATORS