How to Install Shlink on Void Linux
Shlink is a self-hosted URL shortener and link management platform. This tutorial will guide you through the process of installing Shlink on Void Linux.
Prerequisites
Before proceeding with the installation, make sure you have the following prerequisites:
- A running instance of Void Linux.
- Basic knowledge of the command line interface.
Step 1: Install Dependencies
First, update the package list and install the required dependencies.
sudo xbps-install -S nginx mariadb mariadb-client php8-fpm php8-mysqli php8-gd php8-intl php8-xml php8-json php8-zip php8-tidy php8-curl
Step 2: Install Shlink
Next, download the latest stable version of Shlink from the official GitHub repository.
wget https://github.com/shlinkio/shlink/releases/latest/download/shlink_2.x.x.zip
Unzip the downloaded archive to the /var/www directory.
sudo unzip shlink_2.x.x.zip -d /var/www/
Rename the extracted directory to shlink.
sudo mv /var/www/shlink_2.x.x /var/www/shlink
Step 3: Configure Nginx
Create a new virtual host configuration for Nginx.
sudo nano /etc/nginx/conf.d/shlink.conf
Add the following configuration to the file.
server {
listen 80;
server_name shlink.example.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_index index.php;
fastcgi_pass unix:/run/php-fpm.sock;
}
}
In this configuration, replace shlink.example.com with your own domain name.
Save and close the file.
Step 4: Configure MariaDB
Create a new database and user for Shlink in MariaDB.
mysql -u root -p
Enter your root password when prompted.
CREATE DATABASE shlink;
GRANT ALL PRIVILEGES ON shlink.* TO 'shlink_user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
In this example, replace password with a secure password for the shlink_user account.
Step 5: Configure Shlink
Copy the example configuration template to the configuration directory.
sudo cp /var/www/shlink/config/autoload/local.php.dist /var/www/shlink/config/autoload/local.php
Edit the configuration file.
sudo nano /var/www/shlink/config/autoload/local.php
Change the database settings to your own settings.
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common\EnvHelper;
return [
'dependencies' => [
'params' => [
'entity_manager' => [
'connection' => [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'port' => 3306,
'dbname' => 'shlink',
'user' => 'shlink_user',
'password' => 'password',
'charset' => 'utf8mb4',
],
],
],
],
// Other settings...
];
Save and close the file.
Step 6: Initialize Shlink
Now, initialize Shlink's database schema and create the first user account.
cd /var/www/shlink
sudo php bin/cli db migrate
sudo php bin/cli user:create
Follow the prompts to create a new user account.
Step 7: Restart Services
Finally, restart the Nginx and PHP-FPM services.
sudo systemctl restart nginx
sudo systemctl restart php-fpm
Conclusion
You have successfully installed Shlink on Void Linux. You can now access the Shlink web interface using your domain name in a web browser.