Help standing up a self-hosted Lemmy instance
I'm trying to stand up a Lemmy instance, and for some reason I'm just not getting it. I've got a fair bit of experience in Linux and Docker. NPM is new to me, but doesn't seem difficult.
I've looked over several walkthroughs but it seems like they all don't quite work right. Does someone have a clear step-by-step that works, or could take the time to remote in and help me get this up?
I'm running on VMWare ESXi, and I've tried both Debian and Ubuntu to get the server up. Closest I got, the Docker containers would start but seem to be throwing errors internally and don't connect to one another.
So I wanted to make a top-level post: I've got a set of example files, and instructions, that will work 100% of the time on Debian. What do you guys think would be the best way to share them? A post here and the files shared on Google Drive? GitHub? Definitely open to suggestions, but I don't want anyone to struggle with it as hard as I have.
oh man. super valuable. I would love to have that, as setting up Lemmy on Debian 12 is in my near future.
Here we go:
Example files
Any place you see <something>, you need to change it to fit and omit the <>. If something <matches> in two differet places <matches> like this, make sure they match when you're done as well. Specifically, the postgres user and password in the lemmy docker file and the lemmy.hjson.
Finally, in Google drive the files end in .txt so you can view them. You'll need to correct the file names when you download them if you intend to use them. You should have two docker-compose.yml, one in each of the two directories you create, and one lemmy.hjson.
From a fresh CLI Debian 11 install:
Please note I am not addressing federation or SSL or true hosting yet. I haven't got that far yet. But if you can get the damn thing running, the last mile shouldn't be too bad.
Thank you! This is helpful.
I will probably be installing it bare metal atop Debian (no Docker), but this is still quite useful.
BTW I think if you indent your list of commands by 4 spaces, it will render better:
Good note, thanks. Just made the change.
Hopefully this will help someone. This seems to work for me. Subscribed communities update, I am able to post. I'm the only user right now on my server. NPM took me a bit of messing around with the config but I think I have everything working, some of this may be redundant / non functional but I don't have the will to go line by line to see what more I can take out. Here is how I have it configured. Note that some things go to the Lemmy UI port and some to the Lemmy port. These should be defined in your docker-compose if you're using that. (Mine is below)
On the first tab in NPM, "Details" I have the following:
On the Custom Locations page, I added 4 locations, you have to do one for each directory even though the ip/ports are the same.
Repeat the above for "/feeds", "/pictrs", and "/nodeinfo". The example file they give also says to have ".well_known" in there but as far as I know that's just for Let's Encrypt which NPM should be handling for us.
On the SSL tab, I have a Let's Encrypt certificate set up. Force SSL, HTTP/2 Support, and HSTS Enabled.
On the Advanced tab, I have the following:
I probably should add in my docker compose file as well... I'm far from a docker expert. This is reasonably close to their examples and others I found. I removed nginx from in here since we already have a proxy. I disabled all the debug logging because it was using disk space. I also removed all the networking lines because I'm not smart enough to figure it all out right now. If you use this, look out for the < > sections, you need to set your own domain/hostname, and postgres user/password.
There's another post over here https://fernchat.esotericmonkey.com/post/277 with a similar setup, less stuff in the Advanced tab. If I'm bad at explaining maybe another guide will help.
This worked for me, with one note:
<dbuser> and <dbpassword> need to be lemmy and password if you're using the stock lemmy.hjson file, or the lemmy_lemmy_1 container will get stuck in a reboot loop. There's no define in the stock file in githubusercontent currently for those, so you have to add them by hand.
For security, you have to change these.
I'm giving it a go at the moment. Have you looked at the ansible playbook available at https://github.com/LemmyNet/lemmy-ansible ?
I did. I could never get ansible to work when I was setting up the same machine. If you know how to set the inventory file up for that, I'm all ears.
I'm just going through it now. I'll keep you posted
I'm currently hitting an issue of lets encrypt failing to authenticate using the .well-known. The domain in the hosts file is lemmy.domain.com though I have a feeling this may have to be the FQDN. the base domain is currently being used by matrix to serve antoher .well-known so it looks like I'll have to add another page there somewhere.
yes, the domain in the hosts file needs to be the fqdn. Let's encrypt will look for the auth file at the root of that. if you are already using this fqdn/webroot you'll need another cname.
I don't think I'm using the root for anything, just domain.com/.well-known/matrix/server. Would I be able to serve the challenge at domain.com/.well-known/acme-challenge/stringofcharacters?
I think so. letsencrypt will only be looking for the file that certbot creates, so as long as it can resolve the fqdn to your host and port 80 (http://yourdoma.in) is navigable, then you should be good.
certbot certonly --manual is what I need though I think cloudflare or something else is making it only resolve to https. I'm going to shelf this for now and come back to it later. Thanks for your help
Ansible was a breeze once I got it going.
Could you post your inventory file?
Sorry that these are screenshots and not files, but I'm working through Chrome Remote Desktop so my options are a bit limited. This is what I get when I execute 'ansible-playbook -i inventory/hosts lemmy.yml' regardless of whether I have it set to terry@ or root@, and whether I use --become or not.
Maybe you've already looked into this, but I checked the playbook and the error above is occuring when Ansible tries to run this command:
test -e /usr/bin/python || (apt -y update && apt install -y python3-minimal python3-setuptools)
If you manually run the part of the command in parentheses above you'll probably get the Release file error also listed above, and from there you might be able to find out what's up. I think that error usually has to do with your repository setup and/or the version of Ubuntu youre running, but Google can hopefully tell you for sure.
Did you try the docker-compose file referenced in these instructions? It worked first try for me. The hardest part was proxying externally. I'm used to using SWAG so I had to get the nginx config working with SWAG.
https://join-lemmy.org/docs/en/administration/install_docker.html
I just set it up from a git checkout, and it was pretty involved -- the build instructions are actually quite a bit better than usual for development software at this stage, but it's still a complicated process with some changes vs. what's in the instructions. If you're open to that route, I can try to document what I did in more detail + send it along and give some help if you get stuck.
Not the OP but I would appreciate it. I got stuck with building the lemmy image. Not sure why they don't just use a published image
EDIT - found the problem - the docker compose file has the build options enabled for the lemmy image and the published image commented out
EDIT 2 - latest issue - 404: FetchError: request to http://lemmy:8536/api/v3/site? failed, reason: getaddrinfo EAI_AGAIN lemmy
The furthest I got last night, that was where I got stuck as well.