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.
Shlink requires PHP 7.3 or newer to run. To install PHP on macOS, use Homebrew by running the following command:
brew install php
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
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
Navigate to the directory where the repository was cloned:
cd shlink
Now, run the following command to install the dependencies:
composer install
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';
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:
DB_NAME
, DB_USER
, and DB_PASSWORD
settings to match the database name, user, and password that you created in Step 5.SECRET_KEY
setting to a secure, random value.Save the changes to the .env
file.
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! [] []
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!
Alternatively, for the best virtual desktop, try Shells!