What is Lemmy?
Lemmy is an open-source, federated link aggregator similar to Reddit and built with Rust. -https://lemmy.ml/
- Log into the Linux device
- Run the following commands in a terminal window
# update software repositories
sudo apt update
# install available software updates
sudo apt upgrade -y
# install prerequisites
sudo apt install git build-essential gcc libssl-dev pkg-config libpq-dev curl gnupg2 espeak postgresql -y
# enable the postgresql service and start it
sudo systemctl enable postgresql --now
# connect to postgresql
sudo -u postgres psql postgres
# create lemmy database user
create user lemmy with password 'L3mmy' superuser;
# create lemmy database
create database lemmy with owner lemmy;
# close postgresql connection
exit
# add nodejs software repository
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
# install nodejs
sudo apt install nodejs -y
# install yarn
sudo npm install -g yarn
# create lemmy user
sudo useradd -m -d /opt/lemmy lemmy
# install rust, enter 1 at the prompt
curl https://sh.rustup.rs -sSf | sh
# configure the shell
source $HOME/.cargo/env
# clone the lemmy git repository
git clone https://github.com/LemmyNet/lemmy.git ./server
# change directory to the source code
cd server
# build lemmy
cargo build --release
# change directory out of lemmy server
cd ..
# move lemmy to /opt/lemmy
sudo mv ./server /opt/lemmy/
# switch user to lemmy
sudo su lemmy
# change directory to lemmy home
cd ~
# print working directory, should output /opt/lemmy
pwd
# clone lemmy frontend
git clone https://github.com/LemmyNet/lemmy-ui.git --recurse-submodules ./lemmy-ui
# change directory to lemmy-ui
cd lemmy-ui
# clean npm cache
npm cache clean --force
# install npm dependencies
npm install
# fix npm vulnerabilities
npm audit fix
# build lemmy-ui
yarn build:prod
# exit lemmy shell
exit
# create lemmy service file
sudo nano /etc/systemd/system/lemmy.service - Paste the following configuration into lemmy.service
[Unit]
Description=Lemmy[Service]
User=lemmy
Group=lemmy
Environment=LEMMY_DATABASE_URL=postgres://lemmy:L3mmy@localhost:5432/lemmy
ExecStart=/opt/lemmy/server/target/release/lemmy_server
WorkingDirectory=/opt/lemmy/server[Install]
WantedBy=multi-user.target - Press CTRL+O, Enter, CTRL+X to write the changes
- Continue with the following commands
# create lemmy-ui service bash file
sudo nano /opt/lemmy/lemmy-ui/lemmy-ui.sh - Paste the following configuration into lemmy-ui.sh
#!/usr/bin/bash
/usr/bin/node /opt/lemmy/lemmy-ui/dist/js/server.js - Continue with the following commands
# make lemmy-ui.sh executable
sudo chmod +x /opt/lemmy/lemmy-ui/lemmy-ui.sh
# create lemmy service file
sudo nano /etc/systemd/system/lemmy-ui.service - Paste the following configuration into lemmy-ui.service
[Unit]
Description=Lemmy-UI[Service]
ExecStart=/opt/lemmy/lemmy-ui/lemmy-ui.sh
Restart=always
User=lemmy
Group=lemmy
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/opt/lemmy/lemmy-ui[Install]
WantedBy=multi-user.target - Press CTRL+O, Enter, CTRL+X to write the changes
- Continue with the following commands
# reload systemd services
sudo systemctl daemon-reload
# start lemmy service on boot and now
sudo systemctl enable lemmy --now
# start lemmy-ui service on boot and now
sudo systemctl enable lemmy-ui --now - Open a web browser and navigate to http://DNSorIP:1234
- Enter a username, email and password to create a site administrator account > Click Sign Up
- Enter a site name and any additional optional values > Click Create
- Welcome to Lemmy
Sources: https://join-lemmy.org/docs/en/contributing/local_development.html,
https://join-lemmy.org/docs/en/administration/from_scratch.html