How to Install Shlink on OpenSUSE Latest

Shlink is a self-hosted URL shortener built with PHP, REST API, and Doctrine ORM. It allows users to shorten long URLs, track clicks on the links, and manage link tags. In this tutorial, we will show you how to install Shlink on OpenSUSE Latest.

Prerequisites

Step 1: Download Shlink

First, download the latest version of Shlink from the official website. You can download it by running the following command:

$ wget https://github.com/shlinkio/shlink/releases/latest/download/shlink_X.Y.Z.zip

Replace X.Y.Z with the version number you want to download.

Once the download is complete, extract the downloaded package using the following command:

$ unzip shlink_X.Y.Z.zip -d shlink

This will extract the Shlink package into the shlink directory.

Step 2: Install Dependencies

Next, navigate to the shlink directory and install the dependencies using Composer by running the following command:

$ cd shlink
$ composer install

This will install all the required dependencies for Shlink. It may take a few minutes to complete the installation.

Step 3: Configure the Database

Before moving forward, we need to create a database and user for Shlink. Log in to MariaDB/MySQL and run the following commands to create a new database and user:

$ mysql -u root -p
Enter password: 

MariaDB [(none)]> CREATE DATABASE shlink_db;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON shlink_db.* TO 'shlink_user'@'localhost' IDENTIFIED BY 'your_password';
MariaDB [(none)]> FLUSH PRIVILEGES;

Replace your_password with a strong password for the database user.

Step 4: Configure the Application

Next, we need to configure the Shlink application. Rename the .env.dist file to .env by running the following command:

$ mv .env.dist .env

Open the .env file using a text editor and update the following parameters:

DATABASE_URL=mysql://shlink_user:your_password@localhost/shlink_db
SECRET_KEY=some_random_string
ENABLE_TRACK_PARAM=1

Replace your_password with the password that you used for the database user. The SECRET_KEY parameter should be a random string of characters.

Step 5: Create Tables

Next, we need to create the database tables for Shlink. Run the following command to create the tables:

$ php bin/cli db:create
$ php bin/cli db:migrate

Step 6: Configure Apache/Nginx

If you are using Apache, create a new VirtualHost file for Shlink using the following command:

$ sudo nano /etc/apache2/vhosts.d/shlink.conf

Add the following lines to the file:

<VirtualHost *:80>
    ServerName your_domain.com
    ServerAlias www.your_domain.com
    DocumentRoot /var/www/shlink/public

    <Directory /var/www/shlink/public>
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>

    ErrorLog /var/log/apache2/shlink_error.log
    CustomLog /var/log/apache2/shlink_access.log combined
</VirtualHost>

Replace your_domain.com with your domain name.

For Nginx, create a new server block by running the following command:

$ sudo nano /etc/nginx/conf.d/shlink.conf

Add the following lines to the file:

server {
    listen 80;
    server_name your_domain.com www.your_domain.com;

    root /var/www/shlink/public;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
}

Replace your_domain.com with your domain name.

Save and close the file.

Step 7: Restart Apache/Nginx

Finally, restart Apache/Nginx to apply the changes:

$ sudo systemctl restart apache2

or

$ sudo systemctl restart nginx

Step 8: Access Shlink

Open your web browser and navigate to http://your_domain.com. You will see the Shlink login page. Log in with the username admin and the password admin (you can change the password later).

Congratulations! You have successfully installed Shlink on OpenSUSE Latest. You can now start using it to create short URLs and track clicks on them.

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!