How to Install Liteshort on Linux Mint

Liteshort is a lightweight self-hosted URL shortener built with Go. In this tutorial, we will show you how to install Liteshort on Linux Mint.

Prerequisites

Before you start with the installation, make sure you have the following prerequisites:

  • A Linux Mint system with sudo privileges
  • Go programming language installed
  • Git installed
  • MariaDB/MySQL installed and running

Step 1: Clone the Liteshort Repository

First, you need to clone the Liteshort repository from Github. To do this, open a terminal and run the following command:

git clone https://git.ikl.sh/132ikl/liteshort.git

Step 2: Build the Liteshort Binary

After cloning the Liteshort repository, navigate inside the cloned directory and build the Liteshort binary using the following command:

cd liteshort
go build -o liteshort cmd/main.go

Step 3: Configure the Liteshort Database

Before running the Liteshort binary, you need to configure the Liteshort database. To do this, log in to MariaDB/MySQL using the following command:

mysql -u root -p

Enter the root password when prompted. Once you're in MariaDB/MySQL, create a new database for Liteshort using the following query:

CREATE DATABASE liteshort;

Next, create a new user for Liteshort using the following query:

CREATE USER 'liteshort'@'localhost' IDENTIFIED BY 'your_password';

Replace your_password with a strong password.

After creating the Liteshort user, grant all privileges to this user on the Liteshort database using the following query:

GRANT ALL PRIVILEGES ON liteshort.* TO 'liteshort'@'localhost';

Once the privileges are granted, exit the MySQL shell using the following command:

exit;

Step 4: Configure the Liteshort Configuration File

Now that the Liteshort database is ready, you need to configure the Liteshort configuration file. To do this, navigate to the liteshort/config directory and copy the config.example.json file to config.json using the following command:

cd config
cp config.example.json config.json

Then, open the config.json file in your favorite text editor and update the values to match your configuration. You need to update the following values:

  • database: Update the name, username, and password fields to match the database credentials you created earlier.
  • server: Update the listen_address field if you want to change the default Liteshort listening address and port.
  • app: Update the domain field to match your domain name.

Step 5: Run the Liteshort Binary

After configuring the Liteshort binary, you can run the binary using the following command:

./liteshort

Once the binary is running, you can access the Liteshort web interface by visiting http://localhost:8080 in your web browser.

Conclusion

In this tutorial, you learned how to install Liteshort on Linux Mint. Liteshort is a lightweight and powerful URL shortener that can help you manage your URL shortening needs.