Shlink is a free and open-source URL shortener tool that enables you to track access to your shortened links. It is a self-hosted application that you can install on your own server.
In this tutorial, we will show you how to install Shlink on Fedora Server latest.
Before beginning this tutorial, you will need:
First, connect to your Fedora Server latest via SSH and update the system packages to their latest versions:
sudo dnf update -y
The Shlink application requires a few dependencies to be installed on your system. To install these dependencies, run the following command:
sudo dnf install -y php-fpm php-cli php-mbstring php-json php-mysqlnd php-xml php-intl php-opcache php-apcu nginx mariadb-server
Composer is a PHP dependency management tool. It enables you to manage your project's dependencies easily. To install Composer, run the following command:
sudo curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Now, create a directory where you want to install Shlink. In this example, we will use the /var/www/shlink directory:
sudo mkdir /var/www/shlink
cd /var/www/shlink
Clone the Shlink source code from GitHub:
sudo git clone https://github.com/shlinkio/shlink.git .
Install Shlink dependencies:
sudo composer install --no-dev
Generate the JWT secret key:
sudo bin/cli jwt:generate-key -f
Create the upload directory:
sudo mkdir var/uploads
sudo chmod 775 var/uploads
sudo chown -R apache:apache var/uploads
Copy the config file:
sudo cp config/autoload/local.php.dist config/autoload/local.php
Edit the config file, setting the database connection information:
sudo nano config/autoload/local.php
Find the following section:
'shlink_db' => [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'shlink',
'password' => 'secret',
'dbname' => 'shlink',
'charset' => 'utf8mb4',
],
Replace the database connection information with your own:
'shlink_db' => [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'shlink_user',
'password' => 'password123',
'dbname' => 'shlink_db',
'charset' => 'utf8mb4',
],
Save and exit the file.
Migrate the database schema:
sudo bin/cli db:create
sudo bin/cli db:migrate
sudo bin/cli db:seed
Create a new Nginx virtual host configuration file:
sudo nano /etc/nginx/conf.d/shlink.conf
Add the following content to the file:
server {
listen 80;
server_name your_domain.com;
root /var/www/shlink/public;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/www.sock;
# fastcgi_pass 127.0.0.1:9000; # Use this line instead if you are using TCP.
}
}
Replace the your_domain.com
with your own domain name.
Save and exit the file.
Test the Nginx configuration:
sudo nginx -t
If the configuration is successful, reload the Nginx to take effect.
sudo systemctl restart nginx
Allow HTTP and HTTPS traffic on your server firewall.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Open your web browser and enter your server's IP address or domain name. You should see the Shlink homepage.
In this tutorial, you learned how to install and configure Shlink on Fedora Server latest. You can now start using Shlink to shorten your URLs and track access to 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!
Alternatively, for the best virtual desktop, try Shells!