Lemmy is a link aggregation and discussion platform that is similar to Reddit. It is a self-hosted alternative that allows users to create their own communities without fear of being censored or controlled by a larger corporation. In this tutorial, we will walk through the steps to install Lemmy on Clear Linux Latest using the command line.
Before we begin, make sure that you have:
Lemmy requires the following dependencies:
Clear Linux makes this process easy with the swupd command. To install all necessary dependencies, enter the following command:
sudo swupd bundle-add devpkg-rust devpkg-redis devpkg-postgresql devpkg-openssl nginx-basic
Lemmy is open-source software, meaning that you can download the installation files from the existing repositories.
Clone the repository using the following command:
git clone https://github.com/LemmyNet/lemmy.git
Build the project to create the Lemmy binary. To do so, enter the following command:
cargo build --release
Install the binary by entering the following command:
sudo install -Dm755 ./target/release/lemmy /usr/local/bin/lemmy
Create a new user by entering the following command:
sudo -u postgres createuser --pwprompt lemmyuser
When prompted, create a password for the new user.
Create a new database by entering the following command:
sudo -u postgres createdb lemmydb -O lemmyuser
Set the password for the newly created database user. Open the PostgreSQL shell:
sudo -u postgres psql
Then enter the following commands to set the password:
ALTER USER lemmyuser WITH PASSWORD 'your_password';
Exit out of the PostgreSQL shell by typing:
\q
Lemmy uses a configuration file named Rocket.toml
. You can create the file like this:
sudo nano /etc/lemmy/Rocket.toml
Configure the file with the following code snippet. Replace your_domain.tld
with your actual domain name or subdomain.
[global]
secret_key = "your_secret_generated_by_lemmy"
db_url = "postgresql://lemmyuser:your_password@localhost/lemmydb"
allowed_origins = ["https://your_domain.tld"]
google_client_id = "your_google_client_id.apps.googleusercontent.com"
google_client_secret = "your_google_client_secret"
[development]
log = "debug"
[testing]
log = "warn"
[release]
log = "info"
Lemmy is a web application, and it needs a web server to function properly. In this tutorial, we will be using Nginx.
Create a configuration file for your domain or subdomain. Replace your_domain.tld
with your actual domain name or subdomain.
sudo nano /etc/nginx/conf.d/your_domain.tld.conf
Configure the file with the following code snippet. Replace your_domain.tld
with your actual domain name or subdomain.
server {
listen 80;
listen [::]:80;
server_name your_domain.tld;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name your_domain.tld;
ssl_certificate /path/to/your/ssl/certificate;
ssl_certificate_key /path/to/your/ssl/private/key;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000;
}
}
Save and close the file.
Test that your Nginx configuration file is valid:
sudo nginx -t
Reload the Nginx service for changes to take effect:
sudo systemctl reload nginx
Run Lemmy in the background with the following command:
nohup /usr/local/bin/lemmy &
This command launches Lemmy in the background and creates a log file in your home directory called nohup.out.
Verify that Lemmy is running:
sudo lsof -i :8000
Output should include something like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
lemmy 23431 clearuser 22u IPv4 583126 0t0 TCP *:8000 (LISTEN)
Visit your domain or subdomain in a web browser. If everything is set up correctly, Lemmy should be running!
If you experience issues, review and verify that all previous steps have been completed successfully.
Congratulations, you have installed Lemmy on Clear Linux Latest!
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!