How to Install Shlink on macOS

Shlink is a self-hosted URL shortener that allows you to create and manage your own short URLs. It is a great tool for businesses, organizations, and personal use. In this tutorial, we will show you how to install Shlink on macOS.

Prerequisites

Step 1: Install PHP

Shlink requires PHP 7.3 or newer to run. To install PHP on macOS, use Homebrew by running the following command:

brew install php

Step 2: Install Composer

Composer is a PHP package manager that is used to install and manage dependencies for Shlink. To install Composer, run the following command:

brew install composer

Step 3: Clone the Shlink repository

Now that PHP and Composer are installed, we can download the Shlink repository. First, navigate to the directory where you want to install Shlink:

cd /path/to/your/folder

Then, run the following command to clone the repository:

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

Step 4: Install Shlink dependencies

Navigate to the directory where the repository was cloned:

cd shlink

Now, run the following command to install the dependencies:

composer install

Step 5: Install and configure MySQL

Shlink uses MySQL as its database. To install MySQL on macOS using Homebrew, run the following command:

brew install mysql

Once MySQL is installed, start the MySQL server:

mysql.server start

Now, log in to MySQL:

mysql -u root

Create a new database for Shlink:

CREATE DATABASE shlink;

Create a new MySQL user:

CREATE USER 'shlinkuser'@'localhost' IDENTIFIED BY 'password';

Grant the user permissions to access the database:

GRANT ALL PRIVILEGES ON shlink.* TO 'shlinkuser'@'localhost';

Step 6: Configure Shlink

In the shlink folder, copy the .env.dist file to .env:

cp .env.dist .env

Open the .env file in a text editor and make the following changes:

Save the changes to the .env file.

Step 7: Run Shlink

To start Shlink, run the following command:

php bin/cli shlink:run

You should see output indicating that Shlink is running:

[2021-10-06 12:01:41] app.INFO: Starting application... [] []
[2021-10-06 12:01:41] app.INFO: Application started! [] []

Step 8: Access Shlink

Shlink should now be accessible at http://localhost:8080 in your web browser. You can click the "Sign up" button to create a new account and start using Shlink.

Congratulations! You have successfully installed Shlink on macOS.

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!