How to Install Shlink on Debian Latest

In this tutorial, we will learn how to install Shlink, a self-hosted URL shortener on Debian latest. Shlink is a popular open-source tool for creating and managing short URLs.

Before we begin, make sure to have the following:

Let's get started with the installation process.

Step 1: Update System Packages

The first step is to update the system packages on your Debian machine. To do that, run the following command:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

Next, we need to install some dependencies required to run Shlink. The following command will install all needed dependencies:

sudo apt install -y curl git unzip php7.4-cli php7.4-mysql php7.4-xml php7.4-mbstring php7.4-curl php7.4-gd php7.4-zip

Once the installation is finished, verify that the required packages have been installed correctly by running the following command:

php -v

You'll see an output message showing your PHP version installed on your system.

Step 3: Install Docker

Shlink is built with Docker, so you'll need to install Docker on your machine. We'll install Docker using the official Docker repository.

You can add the official Docker repository to your system's APT source list by running the following command:

sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

After adding the repository to your system, update the package list.

sudo apt update

Now install Docker and Docker Compose by running the following command.

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose

Docker should now be installed on your machine.

Step 4: Clone the Shlink Repository

Now that we have installed our required dependencies and Docker, it's time to pull the Shlink repository.

We can clone the Shlink repository to our machine using the following command:

git clone https://github.com/shlinkio/shlink.git

After it has completed cloning, navigate to the shlink directory.

cd shlink

Step 5: Start Shlink Instance

The final step is to set up the Shlink instance. We will use Docker Compose to build and run the container.

First, we need to create a .env file, which contains the necessary configuration variables.

To create the .env file, copy the .env.dist file using the following command.

cp .env.dist .env

Next, start the instance by running the following command.

sudo docker-compose up -d

Wait for the process to complete, and then check that the Shlink instance is running by entering this URL in a web browser.

http://{your-server-ip}:8080

You should see the Shlink homepage.

In conclusion, we have successfully installed Shlink on our Debian latest machine. You can now use Shlink for creating and managing short URLs.

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!