this post was submitted on 17 Jun 2023
50 points (89.1% liked)

Selfhosted

39473 readers
628 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:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

So I've been scratching my head for two days trying to get my own lemmy server up and running.

I have limited server hosting experience but I used to design html websites back in high school through wordpress and was able to successfully set up my own mastadon instance so I'm pretty decent at following instructions, but what keeps tripping me up is ansible and how the heck it works.

The instructions (https://github.com/LemmyNet/lemmy-ansible) are telling me to install ansible on my local machine using python3. On my windows machine I installed ansible using python but when i type the ansible command into terminal it gives me no command found. Is linux required as a host machine?

I have an account over at digitalocean and I'm willing to host my own ubuntu machine over there to get my instance running but I cannot for the life of me figure out how ansible is supposed to set up a server on my windows machine. ANY help would be GREATLY appreciated.... I'm tearing my hair out and feel incredibly stupid right now :D

top 29 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 1 year ago (3 children)

If you aren't attached to Ansible, I suggest using Docker to host Lemmy. I found it's instructions, using Docker Compose, to be quite straight forward.

My other 2 cents is that hosting on Windows isn't worth the hassle and there will be a lot less to debug on Ubuntu if you're already comfortable with it.

[–] [email protected] 9 points 1 year ago

Ansible is just a playbook deploying the docker setup. ;)

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

I run mine on Docker as well, but I noticed that the documentation has got some issues, at least if you are frontending with nginx like I am

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

Yeh, all of the instructions seem to assume some flavor of Linux, I was trying to convert all of the scripts into their windows equivalents for a while, but gave up.

[–] [email protected] 12 points 1 year ago

I would not self-host this on Windows; and if you're not a seasoned server administrator I definitely wouldn't use the Ansible (or even docker-compose) methods.

I wrote some bash scripts that will help you deploy on fly.io if you like, which abstracts the hosting layer away a little bit: https://github.com/Veraticus/fly-lemmy

That said if you're not super comfortable in this space then debugging and correcting problems is also going to feel incredibly frustrating, so, just warning you.

[–] [email protected] 8 points 1 year ago (2 children)

Install wsl for windows Ubuntu default.(can install wsl in PowerShell).

Install Ansible in wsl, create ssh keys to your VPS, follow those instructions.

On my Ubuntu server I did literally nothing but the ssh key generation.

[–] Eddie 2 points 1 year ago

Following the instructions using wsl and I get met with the following error after running the playbook:

"fatal: [[email protected]]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host example.com port 22: Network is unreachable", "unreachable": true}"

Where do I enter my ssh info?

[–] [email protected] 1 points 1 year ago (1 children)

I think this is one of the more sensible answers here. If your workstation is windows, then utilize WSL for ansible and deploy onto a ubuntu or debian host (I'm assuming it works fine on debian, I used ubuntu). You might run into some issues with ansible dependencies as the readme doesn't seem to cover everything from what i remember, but once ansible works and has the correct configs, deployment is super easy.

[–] [email protected] 0 points 1 year ago (1 children)

Yeah Ansible I had to set the path variable and did the ssh key generation. Other than that my lemmy was up and running in like 10 minutes all automated. You can go back and change the config by rebuilding the yaml. It's not bad at all.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

I ran into some dependency issues(needed to install ansible-collection-community-docker on my fedora workstation), but after that it ran fine and installed everything first run. I made some adjustments to the inventory config afterwards, but aside from that it just worked.

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

sadly, none of these is worth implementing. Remember, Windows is designed to break. MS has millions of tiny levers to flick, and they don't care if their mindless flicking fucks up your work. Worse of all, the law protects them from flicking to destroy you out of spite. Best thing to do is just use linux. Or design our own OS. Since Linux itself is slowly collapsing under the weight of MS bullshit. And god forbid that shithole IOS.

[–] [email protected] 8 points 1 year ago (1 children)

I highly doubt Ansible works on Windows and in general it is really not a good idea to host anything on Windows as it is way to insecure and also not meant for it.

If you install something on your DO VPS maybe try Yunohost: https://yunohost.org/

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

Yunohost is awesome. I use it myself for my Lemmy instance. Unfortunately because YunoHost doesn't use containers and Lemmy now requires psql 15 it's stuck on Lemmy 0.16.7. So it's not ideal if you want the latest version of the sure to be quickly changing Lemmy software.

[–] [email protected] 6 points 1 year ago (1 children)

Also going to suggest using the docker containers as well. It’s much easier to get up and running, plus Docker knowledge is great to have under your belt.

[–] [email protected] 5 points 1 year ago

The ansible playbook just deploys docker containers. It does nginx proxy config, deploys the docker software, and then creates the compose file and deploys the containers. The reality is the ansible deploy and docker deploy both use docker. The ansible playbook just does more of everything all at once in an automated way.

[–] [email protected] 6 points 1 year ago (1 children)

After a looooong day of trial and error and basically learning all of this from scratch, I am happy to say I have finally gotten my own instance up and running!

HUGE credits goes to @[email protected] for creating a script to install Lemmy in just a few simply commands. Definitely reccomend checking out his work if you're brand new to all of this: https://lemmy.world/post/249889

Although I ended up taking the "easy way out", I do want to take a moment to thank all of you for taking the time to comment and contribute time to help me sort out this problem. This is such a warm and welcoming communtiy and I really appreciate it. Cheers from SoCal!

[–] [email protected] 4 points 1 year ago

Amazing!!! I'm so glad to hear I was able to help you get things set up! You're my first success story, good to know it's actually working for people!

Welcome to the self-hosted Fediverse!

[–] [email protected] 4 points 1 year ago

If you're running python on windows then you need to make sure you're environment variables are updated or else the commands the instructions tells you to put into cmd will do nothing because the path to the application isn't defined.

[–] [email protected] 4 points 1 year ago

Not sure how ansible works on Windows but you could use Windows Subsystem for Linux, install ansible on that and then off you go.

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

I totally feel you, it took me 4 days on different computers until I gave in and got a new clean server just for lemmy. Then I used the Docker way of hosting. But even with that the documentation didn't tell me everything, so I had to change the second nginx config file (the one with server_name my_domain.tld;) so now this is working even with the web-workers (for posting comments) and federation with SSL:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}
server {
    server_name jemmy.jeena.net;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header    X-Forwarded-for $remote_addr;
	proxy_set_header Host $http_host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/jemmy.jeena.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/jemmy.jeena.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = jemmy.jeena.net) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name jemmy.jeena.net;
    return 404; # managed by Certbot
}

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

Ansible runs on your local machine, but it executes the setup on your (Linux) server remotely via SSH. I'd definitely recommend the Ansible setup, it was the easiest I tried. Are you able to SSH into your server already?

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

The way I did it was to setup WSL and installed Ansible there then used the lemmy ansible script pointing to my lemmy instance VM

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

Stop what you are doing and use https://github.com/ubergeek77/Lemmy-Easy-Deploy

It is super easy this way.

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

On my windows machine I installed ansible using python but when i type the ansible command into terminal it gives me no command found. Is linux required as a host machine?

Its possible the installer didnt properly add the ansible exectuable to the PATH environment variable. You can do this manually, or just use the command prompt and cd to the directory that ansible is installed.

You can do a search of "environment" and edit the variables yourself. It does require a reboot to take effect.

System>Path is what you want to set. And no matter what you need to know where the ansible installer is.

Personally I used an exsiting linux box in my lab. If i didnt have that, then maybe the windows subsystem for linux would be my next step. I would avoid python/ansible in windows if i could.

Additionally you COULD just install ansible on the local VPS. You basically just set the localhost to be the destination in the hosts config.

Something like this

https://gist.github.com/alces/caa3e7e5f46f9595f715f0f55eef65c1

https://www.ntweekly.com/2021/03/30/run-ansible-playbooks-on-your-localhost-machine/

I would also do some basic lockdown of the machine. Set SSH to key based auth only. Setup the firewall and block all ports other than 80/443 and limit 22 to your home IP or something. Limit SSH access to only an account or group etc etc.

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

I just set one up using docker. Went surprisingly smoothly.

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

Well the server to run lemmy must be at least from that repo debian based. (Ubuntu or debian). Per the requirements.

Anisvle prolly could run on windows. Never tested.

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

I would suggest Lemmy-Easy-Deploy. It had my instance up and running in < 5 minutes.

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

Assuming docker and docker compose are installed on a Linux machine and you have some kind of front end proxy with a valid cert available, just create a folder you have write access to and unzip the file from here: https://cloud.socdojo.com/s/yrATyMZtNTFiLjY

There should be 3 files in it, docker-compose.yml, lemmy.hjson, and nginx.conf

Notable areas to update:

Line 55 of docker-compose.yml is where any attachments of posts get stored, in the case of my files /mnt/NAS/Lemmy where they get offloaded to a remote NAS, change as needed, but the folder should be set with a 'sudo chown 991:991 /mnt/Lemmy' to allow pictrs to write to it. This folder should be created first and the permissions changed before bringing things up.

Lines 20 of nginx.conf and line 17 of lemmy.hjson should match as your domain name, I don't know if the nginx name actually matters honestly but it works for me.

Lines 44 of docker-compose.yml and line 38 of lemmy.hjson should match for your database password

Line 9 of docker-compose.yml the first number is whatever you want your inbound proxy port to be, in the config it's set to 1234

Lines 20 of the docker-compose.yml and line 12 of nginix conf should have the same port number, set as 1234 in these files.

Any other fields tagged as 'ChangeMe' are pretty self explanatory and don't have to match anywhere else, Just updated them to be what you need for email, admin account info, domain hostname, a site title, etc.

After that it should all work, just point your front end proxy at the port you set in the docker compose and away it goes.

docker compose up -d

load more comments
view more: next ›