LIVEReading: Run Your Own URL Shortener on Any ServerTotal time: 10 minSteps: 5Worked first time: 72% LIVEReading: Run Your Own URL Shortener on Any ServerTotal time: 10 minSteps: 5Worked first time: 72%
CBW
Run Your Own URL Shortener on Any Server
Mediumgithub.com/yourls/yourls2026-07-11

Run Your Own URL Shortener on Any Server

YOURLS lets you host a private URL shortener on your own server. You get full control over your links, click stats, and data — no third-party service required.

// Build stats

  • Total time10 min
  • Number of steps5
  • DifficultyMedium
  • Worked first time72%
// Before you start

What you need

  • A web hosting account or VPS with PHP 7.4+ and MySQL/MariaDB
  • FTP client (like FileZilla) or cPanel File Manager access
  • A domain name pointed at your server
  • A MySQL database name, username, and password (create one in cPanel or your host's dashboard)
  • Basic comfort navigating a web browser and uploading files
01
Step 1 of 5

Download the latest YOURLS release

2 min

Go to the official YOURLS releases page and download the latest ZIP file. This contains all the PHP files you need. You do not need to install anything on your computer first.

Terminal · mac
$ https://github.com/YOURLS/YOURLS/releases/latest — click the .zip asset to download
What you should see
A file named something like yourls-1.9.2.zip saved to your computer.
This might happen

Downloading the raw GitHub repo ZIP instead of a release ZIP can include extra dev files.

Always use the Releases page link above, not the green 'Code > Download ZIP' button on the main repo page.

02
Step 2 of 5

Upload and extract YOURLS to your server

5 min

Upload the ZIP to your web server's public folder (usually called public_html or www) using FTP or your host's File Manager. Then extract it there. You can rename the extracted folder to something short like 'go' or 'link' — this becomes part of your short URL (e.g. yourdomain.com/go/).

Terminal · mac
$ Upload yourls-x.x.x.zip to public_html/ via FTP or cPanel File Manager, then right-click > Extract.
What you should see
A folder like public_html/yourls/ (or whatever you renamed it) containing files including index.php and a /user subfolder.
This might happen

Extracting creates a nested folder like yourls-1.9.2/yourls — make sure you end up with the files directly inside your chosen folder.

Move the inner folder contents up one level, or rename the extracted folder to your preferred name.

03
Step 3 of 5

Create your config file from the sample

3 min

Inside the /user folder you just uploaded, there is a file called config-sample.php. You need to make a copy of it and rename the copy to config.php. Then open config.php in a plain text editor (Notepad on Windows, TextEdit in plain-text mode on Mac, or your host's File Manager editor) and fill in your database details and a secret password.

Terminal · mac
$ In File Manager: copy user/config-sample.php, rename the copy to user/config.php, then open it and edit these lines:
$
$ define( 'YOURLS_DB_HOST', 'localhost' ); // usually localhost
$ define( 'YOURLS_DB_USER', 'your_db_username' );
$ define( 'YOURLS_DB_PASS', 'your_db_password' );
$ define( 'YOURLS_DB_NAME', 'your_db_name' );
$ define( 'YOURLS_SITE', 'https://yourdomain.com/yourls' ); // your full URL
$ define( 'YOURLS_COOKIEKEY', 'put any long random string here' );
$
$ $yourls_user_passwords = array(
$ 'your_admin_username' => 'your_admin_password',
$ );
What you should see
A saved user/config.php file with your real database credentials and site URL filled in.
This might happen

Leaving YOURLS_SITE with the wrong URL breaks all short links.

Set YOURLS_SITE to the exact URL where YOURLS lives, with no trailing slash. Example: https://example.com/go

04
Step 4 of 5

Run the one-time install script

2 min

YOURLS has a built-in installer that creates the database tables automatically. You just visit a special URL in your browser. This only needs to be done once.

Terminal · mac
$ Open your browser and go to:
$ https://yourdomain.com/yourls/admin/install.php
$
$ (Replace 'yourls' with whatever folder name you used.)
What you should see
A page that says 'Congratulations! YOURLS is now installed and ready to use.' with a link to your admin area.
This might happen

Page shows a database connection error.

Double-check YOURLS_DB_HOST, YOURLS_DB_USER, YOURLS_DB_PASS, and YOURLS_DB_NAME in config.php. Many shared hosts use a db username prefix like accountname_dbuser.

05
Step 5 of 5

Log in and shorten your first URL

2 min

After install, go to your admin panel. Log in with the username and password you set in config.php. You'll see a simple form where you paste a long URL and click Shorten. YOURLS generates a short link instantly and tracks every click.

Terminal · mac
$ Go to: https://yourdomain.com/yourls/admin/
$
$ Enter the username and password from your config.php $yourls_user_passwords line.
What you should see
A dashboard showing a URL input box. Paste any long URL, click Shorten, and get back a short link like https://yourdomain.com/yourls/abc12.
This might happen

Short links return a 404 error when clicked.

Your server needs mod_rewrite enabled and an .htaccess file. YOURLS includes one — make sure it uploaded correctly and that your host allows .htaccess overrides (ask support to enable AllowOverride All).

// Status

cooked. baked. worked.

A working private URL shortener at your own domain. You can shorten links through the admin panel, share them publicly, and see click counts and basic stats for every link — all stored on your own server.

// the honest bit

The honest part

YOURLS requires real web hosting with PHP and MySQL — it cannot run on your laptop without extra software like XAMPP. Shared hosting (Bluehost, SiteGround, DreamHost, etc.) works fine and is the easiest path. The admin panel is functional but plain; it was not designed to be pretty. If you want HTTPS short links (you should), your domain needs an SSL certificate — most hosts provide free Let's Encrypt certs via cPanel. Plugin installation requires uploading files to the /user/plugins/ folder manually.