๐ Yourls
Yourls is a self-hosted F/OSS URL shortener that you can use to track, edit and enhance your links!
YOURLS (Code) is a self-hosted Free and Open Source link shortener that you can run to do redirects on your own domain or any other domain.
While some are very against link shorteners, some are still happy to use them, and they're certainly widely used. Google did shut down their own link redirection service, but that doesn't mean you shouldn't run one yourself!
So why do people use link redirection?
- Save on characters (this is often not necessary)
- Collect analytics on clicked links
- Restricting access to content after it's been published
- Creating time-sensitive links
Link shorteners have a lot of uses, and while you may not want to shorten every link, they can sometimes be useful for at least the above reasons.
Yourls has been around for a long time and is one of the most well known link shorteners out there.
Don't let the LAMP stack (PHP + MySQL) scare you โ Yourls seems to be a well-run project that has stood the test of time. Check out their issues ratio.
๐ Features
Yourls is packed with features, and most of these are shared with other link shorteners but are still worth listing out:
- Referrer tracking
- Custom link redirection
- Geolocation checking
- API access
- Stats & Historical click reports
- Plugin support
๐ค As described by AI
YOURLS (Your Own URL Shortener) is an open-source URL shortening application. It allows users to create their own URL shortener service, providing a self-hosted solution to shorten long URLs into shorter, more manageable links. This project is built with PHP and MySQL, offering a customizable and flexible platform that can be easily integrated into other systems or websites. YOURLS provides features such as link tracking, analytics, and keyword-based custom short URLs, making it a versatile tool for managing and analyzing web traffic.
The project is designed for easy installation and use, offering a straightforward setup process and an intuitive web interface. YOURLS supports a variety of plugins that extend its functionality, such as adding security measures, social media integration, and more. It is a popular choice for individuals and organizations looking for a reliable, private, and fully controllable URL shortening service.
๐บ Watch this
DBTech has a great video on Yourls which explains a bit about link shortening in general and how to get started with Docker:
If you want to get the same information, but with an Akamai twist:
๐ Getting started
Before you can run Yourls, you'll need to set up at least two pieces of infrastructure:
- MySQL (the database in which yourls will store information)
- Web server (ex. Apache or NGINX)
While we won't get into either of these, for those who are intimidated we'd suggest skipping to the Docker instructions!
๐ฃ Running with PHP
While we're certainly not PHP experts, the important thing to remember is that PHP is a pre-processor, so files that would normally make up a website make up your PHP app.
That said, the instructions are pretty simple:
- Grab the latest release archive
- Unzip the YOURLS archive
- Copy
user/config-sample.php
touser/config.php
- Fill
user/config.php
with the required settings - Upload the unzipped files to your website, generally in
public_html
orwww
folder - Create a new database (see Configuration โ you can also use an existing one)
- Point your browser to
https://your-own-domain-here.com/admin/
- Follow the rest of the installation procedure (online)
๐ณ Running with Docker
Luckily we can avoid having to set up all the hard stuff, because yourls
has an official docker image!
We can start yourls
and the required MySQL DB for it with docker-compose
version: '3.1'
services:
yourls:
image: yourls
restart: always
ports:
- 8080:80
environment:
YOURLS_DB_PASS: example
YOURLS_SITE: https://example.com
YOURLS_USER: example_username
YOURLS_PASS: example_password
mysql:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: yourls
๐งโ๐ป Want to contribute?
Yourls is a long-lived PHP codebase with lots of contributors, and work left to do โ with 10k โญs it's a great place to help the PHP community and get involved!
๐ฌ Want Awesome F/OSS in your inbox?
We'll send you new articles as soon as they go live.