I’ve been doing things the wrong way for a long time and now it’s time to pass my incompetence onto others.

  • 0 Posts
  • 9 Comments
Joined 1Y ago
cake
Cake day: Jun 07, 2023

help-circle
rss

I have my own server collocated in a data center so I spun up my instance in a virtual machine. All the infrastructure was ready to go and I’ve got a testing and production environment setup between my colo and my home lab. All that to say I’ve done things like this before so it wasn’t that difficult for me. I complied Lemmy from scratch which I do not recommend unless you really know what you’re doing. Docker would be the easiest way but I don’t really use it so I can’t recommend anything there.


Lemmy logs everything, and I mean everything. I haven’t found a setting to dial it back so I’ve banned it from writing to syslog and moved journal to memory only. Here is what I ran to stop it from filling up my disk with logs.

echo 'if $programname == "lemmy_server" then stop' >> /etc/rsyslog.d/ignore-lemmy_server.conf
systemctl restart rsyslog

sed -i 's/#SystemMaxUse=/SystemMaxUse=25M/g' /etc/systemd/journald.conf
sed -i 's/#Storage=auto/Storage=volatile/g' /etc/systemd/journald.conf systemctl restart systemd-journald


I’m curious to see how this all plays out. I’m running my own instance and it will be interesting to see if small instances get excluded on any large ones due to spam or abuse. Not that I plan on letting that happen with mine but I could see it has an anti abuse measure in the future.


curl localhost:8536/api/v3/site now works!

Nice! Sorry my notes are a mess and nothing is in order since I was trying a lot of different things at the time.


Whoops… Yes you are correct. I had switched to git pull since that’s what I will use going forward to update.

I’ve update the above text so hopefully it is a complete guide.


Try this:
sudo -iu postgres psql -c "ALTER USER lemmy WITH SUPERUSER;"

You might need to dump the DB before restarting lemmy_server
sudo -iu postgres psql -c "DROP DATABASE lemmy;"
sudo -iu postgres psql -c "CREATE DATABASE lemmy WITH OWNER lemmy ENCODING 'UTF8' TEMPLATE template0 LC_COLLATE 'C' LC_CTYPE 'C';"


Let me know if it works. I had the same DB migration issues using the install lemmy_server options and found a post, I think on github, about there being an issues with there. I can’t find that post now.


I just updated my comment to fix those two errors. This was copy/paste out of my notes txt file from figuring out how to do this.

A dot after recursive will drop the git files into the current directory. In this case /root/lemmy/
git clone https://github.com/LemmyNet/lemmy.git --recursive .

And don’t run that first cargo command that I’ve since removed. Only the second one, now only one. This uses the git cargo files instead of the crates app (install lemmy_server.)
cargo build --release --target-dir /root/lemmy/ --locked --features embed-pictrs


There is an issue with the cargo build. It works if you build from git as follows. Make sure you are using release tags as the main branch will break things. Current built as of this message is 0.17.3. Both the front and back end need to match. Rustup needs to already be installed and the shell PATH configured.

Database. Follow the doc and then run this command:
sudo -iu postgres psql -c "ALTER USER lemmy WITH SUPERUSER;"

Back end:
mkdir -p /root/lemmy/
cd /root/lemmy/

git clone https://github.com/LemmyNet/lemmy.git --recursive .
git branch -a
git checkout 0.17.3
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"

cargo build --release --target-dir /root/lemmy/ --locked --features embed-pictrs
mv /root/lemmy/release/lemmy_server /usr/bin/lemmy_server

Front end:
mkdir /var/lib/lemmy-ui
cd /var/lib/lemmy-ui
chown lemmy:lemmy .

sudo -u lemmy bash
git clone https://github.com/LemmyNet/lemmy-ui.git --recursive .
git checkout 0.17.3
echo "export const VERSION = \"v$(git describe --tag)\";" > "/var/lib/lemmy-ui/src/shared/version.ts"
yarn install --pure-lockfile
npx browserslist@latest --update-db
yarn build:prod

Past that use the systemd unit files from the build from scratch doc: https://join-lemmy.org/docs/en/administration/from_scratch.html