How to Install Shlink on Linux Mint

In this tutorial, you will learn how to install Shlink on Linux Mint OS. Shlink is a free, open-source URL shortener written in PHP.

Prerequisites

Step 1: Install LAMP Stack

Before installing Shlink, make sure your system has the LAMP stack installed. You can install the LAMP stack by running the following command in your terminal:

$ sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql

Step 2: Install Composer

Next, you need to install Composer to manage dependencies for Shlink. Run the following commands to install it:

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Once the installation is complete, verify that Composer is installed correctly by running:

$ composer -V

Step 3: Install Git

Shlink is hosted on GitHub, so you need to install Git to clone the repository. Run the following command to install Git:

$ sudo apt install git

Step 4: Clone the Repository

Now, you can clone the Shlink repository to your machine by running the command below in your terminal:

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

Move into the cloned directory:

$ cd shlink

Step 5: Install Shlink Dependencies

Use Composer to install the Shlink dependencies by running the following command:

$ composer install --no-dev

Step 6: Create the Shlink Database

Create a new MySQL database for Shlink and grant appropriate permissions to a new user which you will create later:

$ mysql -u root -p
> CREATE DATABASE shlink;
> CREATE USER 'shlinkuser'@'localhost' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON shlink.* TO 'shlinkuser'@'localhost';
> FLUSH PRIVILEGES;
> EXIT;

Step 7: Configure Shlink

To configure Shlink, you need to create an environment file with the name ".env" using the following command:

$ cp .env.dist .env

Update the ".env" file with the database details by modifying the following lines:

DATABASE_URL=mysql://shlinkuser:password@127.0.0.1/shlink

Step 8: Run Shlink Migrations

To create the necessary database tables, run the following command:

$ vendor/bin/doctrine-migrations migrate

Step 9: Configure Apache for Shlink

Create an Apache virtual host configuration for Shlink at "/etc/apache2/sites-available/shlink.conf" using the following command:

$ sudo nano /etc/apache2/sites-available/shlink.conf

Add the following information to the file:

<VirtualHost *:80>
    ServerName shlink.local
    DocumentRoot "/path/to/shlink/public"

    <Directory "/path/to/shlink/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Make sure to replace "/path/to/shlink/public" with the actual path to the Shlink public directory.

Step 10: Enable the Shlink Virtual Host

After you have created the virtual host configuration file for Shlink, you need to enable it by running the following command:

$ sudo a2ensite shlink.conf

Step 11: Restart Apache

Restart Apache to apply the changes:

$ sudo systemctl restart apache2

Step 12: Access Shlink

You can now access Shlink by going to http://shlink.local or some other domain name you might have used in your Apache configuration.

Conclusion

Congratulations! You have successfully installed Shlink on Linux Mint. You can use Shlink as a URL shortener to help organize and manage your links.

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!