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.
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
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
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
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
Use Composer to install the Shlink dependencies by running the following command:
$ composer install --no-dev
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;
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
To create the necessary database tables, run the following command:
$ vendor/bin/doctrine-migrations migrate
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.
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
Restart Apache to apply the changes:
$ sudo systemctl restart apache2
You can now access Shlink by going to http://shlink.local or some other domain name you might have used in your Apache configuration.
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!