Skip to main content

Your Own URL Shortener – YOURLS tutorial

yourls logoTwitter has definitely promoted a new service along the years, the URL shorteners…..Instead of sharing long URLs that restricted the number of tags we could set and the actual content, URL shorteners have helped to maximize the available 140 characters by providing a short new URL (as a redirection) to the long one.


But URL Shorteners has also improved in a general manner the sharing of long URL for SMS, Emails, or actually anywhere, where reducing the URL could save time. (If I cannot copy/paste a long URL, I’ll use my own URL shortener)

If you don’t want to depends on 3rd party service and wish to have your own URL shortener, YOURLS is probably the most popular one.

YOURLS - Screenshot

YOURLS, for Your Own URL Shortener has many benefits:

– Free and OpenSource,

– Could be use as Private (For you only) or Public (Anybody can create short links)

– Customized URL

– Bookmarklets to easily shorten and share links (On Twitter, Facebook, Tumblr)

– Got some stats (Historical click reports, referrers tracking, visitors geo-localization

– Clea interface (In Ajax)

Plugin architecture

– Easy to install

YOURLS - stats screenshot



YOURLS do not require much, only Apache with mod_rewrite enabled, PHP in version 5.2 or greater and MySQL in version 5 or greater.

1) Download YOURLS in your /var/www folder

You can download the latest stable archive here, or directly download the current master branch from git (What I’ll do)

If you prefer to use the stable version (1.7 as of the date of this post), you can simply run

Don’t forget to unzip the archive if you have downloaded the stable version

2) Copy configuration file and fill the required information

You can edit the config.php with nano for example

Your will need to define:

– MySQL user/pass and database. You can use PHPMyAdmin to easily create one.

– YOURLS installation URL, to set the URL you want to point your YOURLS service

– Languages, English per default, but you can set one of the following languages.

– Set a random secret hash (for cookies)

– Username(s) and password(s), you can allow several users

And this should be enough to start, you can modify more settings and add your own if you want.

3) Change ownership of your YOURLS folder to apache user (www-data) to avoid read/write permissions.

4) Enable Apache mod rewrite (if not done yet)

5) Go to http://YourIP/YOURLS/admin to finalize the installation

YOURLS - Installation

6) Set automatic update

If like me you use the version directly from the git repository, you may also want to get latest update regularly. You can simply add a cron job to do it.

and at the end of the file, paste:

This will update your YOURLS folder every day at 0:0 (midnight).

For more information, I recommend you to read the official wiki.

4 thoughts on “Your Own URL Shortener – YOURLS tutorial

  1. Hi, I have Yourls V1.6 installed but now Really confused how to upgrade it to v1.7
    do you have any easy guide for me to follow it?

    been searching around google & still can’t find it.

    Thank you so much

    1. Hi Willy,
      Have you tried the suggested steps from the official website?

      Most important is to backup the database. If you do so, you will be sure not to loose anything. (Like with Phpmyadmin, you just export the full database), then download the latest version and copy paste all its content in your current Yourls folder (Overwritting everything)

      Let me know if you cannot make it.

      1. Hi Karibu,
        Thanks for reply.
        I thought my comment just got deleted or ignored.

        Gonna try it out. Maybe I should try to learn how to backup first. LOL
        really newbie in those stuff. Didn’t have any coding or programing background

        and Then I will try follow the step to upgrade.
        Just afraid after overwrite its gonna wipe out all my shorten link

        Thank you

        1. Hi Willy,
          For the first comment, it needs to be manually approved (To avoid spam). But usually I approve within 1 day.

          You right, better to backup first, I assume you have a MySQL database right?
          If you have phpmyadmin, you should export your yourls database. There is one table called yourls_url, this one includes all your shorten links.

          Let me know if it works.

Leave a Reply

Your email address will not be published. Required fields are marked *