How to Install Shlink on NetBSD

In this tutorial, you will learn how to install Shlink on a NetBSD server. Shlink is a powerful URL shortener platform that can be used for managing and sharing shortened links, as well as tracking clicks and managing tags.

Prerequisites

Before you begin, you will need the following:

Step 1: Install PHP and required PHP extensions

Shlink is written in PHP, therefore, the first step is to install PHP and the required extensions on your NetBSD server.

To install PHP and its extensions, run the following commands:

pkg_add php74-7.4.24
pkg_add php74-curl-7.4.24
pkg_add php74-openssl-7.4.24
pkg_add php74-mbstring-7.4.24
pkg_add php74-pdo_mysql-7.4.24

Step 2: Install MariaDB

Shlink uses a MariaDB database to store its data. You need to install MariaDB server on your NetBSD server.

To install MariaDB, run the following command:

pkg_add mariadb-10.6.3

Step 3: Create a MariaDB user and database for Shlink

After installing MariaDB, you need to create a new user and database for Shlink.

Log in to MariaDB by running the following command:

mysql -u root -p

Create a new user and database for Shlink by running the following commands:

CREATE DATABASE shlink;
GRANT ALL PRIVILEGES ON shlink.* TO 'shlink'@'localhost' IDENTIFIED BY 'shlinkpassword';
FLUSH PRIVILEGES;
EXIT;

Step 4: Install Shlink

Now that you have installed PHP, MariaDB, and created a new user and database for Shlink, you can proceed with installing Shlink.

Download the latest version of Shlink from the official website by running the following command:

cd /tmp
wget https://github.com/shlinkio/shlink/releases/download/v2.5.0/shlink_2.5.0_netbsd_amd64.tar.gz

Extract the downloaded archive by running the following command:

tar -zxvf shlink_2.5.0_netbsd_amd64.tar.gz

Copy the extracted files to the /usr/local/www/shlink directory by running the following command:

cp -R shlink /usr/local/www/

Rename the .env.dist file to .env and configure the file with your MariaDB database information:

cd /usr/local/www/shlink
cp .env.dist .env
nano .env

Edit the following lines to include your MariaDB information:

DATABASE_URL=mysql://shlink:shlinkpassword@localhost:3306/shlink

Step 5: Create the database tables

After configuring the .env file, you need to create the database tables. Use the following command to migrate the database tables:

./bin/cli db:migrate

Step 6: Start the Shlink server

Finally, start the Shlink server by running the following command:

php74 bin/cli server:start

Congratulations! You have successfully installed Shlink on your NetBSD server. You can access the Shlink web interface by visiting http://your_server_ip:8080 in your web browser.

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!