How to Install Your Own URL Shortener Script

In this post I’ll show you how to install a free URL Shortner Script (similar to bit.ly or tinyurl.com) called Yourls.

I use this script in place of a traditional link cloaking script to cloak affiliate links, as well as for tracking links in emails etc. It’s quite robust for a free script, so I highly recommend you use it.

The downside of this script of course is that it’s a little bit technical to install. So, I’ve decided to show you a simple 3 step process to install this script on your own server.

Before you begin, you will need to setup a MYSQL database. If you don’t know how, I created a post on how to setup MYSQL a while back, so follow the steps there then come back to this post.

The following steps assumes that you have a domain you can use (can be a sub-folder / sub-domain on an existing site as well) already installed your MYSQL database, and that you have downloaded the latest version of Yourls.

I’m also assuming that you know how to use a basic FTP program like Filezilla or SmartFTP (or something similar).

Step 1: Upload the script

Once you’ve downloaded the script, you want to upload your script to the desired domain or sub-domain / sub-folder. For this example I will install it in a sub-folder named “go” using my FTP program (I use WS_FTP):

Once you’ve named the folder, simply unzip your copy of Yourls (that you downloaded earlier) and copy the content to the folder, like this:

 

Step 2: Configure Your Script

Note: You will have to locate your newly made MYSQL database, username and password for this.

Once you have the MYSQL information handy, you need to go to your installation and go to the user sub-folder of your installation and locate the file called: config-sample.php

Missing the Config.php File?

I recently downloaded a version of YOURLS and it was MISSING the config-sample.php file. So just in case you’re missing it too… here’s a zip file with the php file:

Your Zip File

You may need to right-click the following links and select Save Link As to download the file to your computer:

CLICK HERE FOR ZIP FILE

Once you’ve located the file, you’d want to edit it…

You can do this generally from within your FTP client software or you can simply edit the file on your hard drive and re-upload it. (I do the former).

Here’s what you need to edit (I’ve circled everything in RED):

I’ve gone ahead and change the default text in the areas I circled, just to emphasize that they need to be changed.

For your “cookie key” field, you can use the free password generator.

IMPORTANT: Once you’ve edited everything, simply save the file (and if needed, re-upload to your server) and rename it from config-sample.php to config.php.

Step 3: Run Install File

You’ve edited the config file and renamed it to config.php, now you want to point your browser to the admin area of your script and install the script!

The admin area can be found here (provided you installed it into the “go” sub-folder like I did): http://yoursite.com/go/admin/

Here you’ll see this:

Click on “Install YOURLS” and let the script run.

Provided you typed everything in properly into the config file, you should see a “success” message like this:

Once you’re done, simply go to the YOURLS admin screen by following the link on the screen (above) or by going to:

http://yoursite.com/go/admin/ (again, provided you installed it in the ‘go’ sub-folder)

Optional House Cleaning:

Because I use this link shortener script to cloak my affiliate links and also to keep track of CTR on various things, I DO NOT setup the front-end (that’s visible to the public) for this script.

Instead, I simply upload a blank index.html file to the directory, so that when someone tries to access the directory: http://yourdomain.com/go/ it only gives them a blank page.

You can do the same by uploading a blank index.html file to your folder.

I’ve included a blank index file in case you don’t know how to create one… (it’s in a zip file so you will have to unzip the file before you upload to your directory):

Your Downloads

You may need to right-click the following links and select Save Link As to download the file to your computer:

BLANK INDEX.HTML FILE

If you choose to make this area public, be sure to edit the files that are already uploaded to the folder.

You’re Done!

You’re ready to start using the script!

First, login to your admin area, then simply enter your desired information:

Then click the “Shorten The URL” button.

You will then get a couple of new boxes that will appear below the area where you entered the information. Just copy the link from this area (all you need to do is left click on the area and it will automatically copy your new link):

And you’re good to go!

So in this case, my “cloaked” url is this: http://supersimplemarketing.com/go/facebook

This Post Is Sponsored By:

Subscribe to my “Near-Daily Newsletter” and I’ll share with you Practical Tips, News & Ideas on internet marketing topics (access to this newsletter is free at the moment, and you can un-subscribe with one click).

If you like this post, then please SHARE IT!

Tags: , ,

Leave A Reply (11 comments so far)

  • TimRN

    Thanks for both yourls and the install instructions. I wouldn’t have figured out what to change in the config.php file by myself. Cheers, Tim

  • Pingback: How to Install Your Own URL Shortener Script | MostTalkedNews.com

  • http://comingsoon... Rachel Webb

    Hi Steven,

    As you know, there are several paid options for “shorteners” out there (I won’t name names). What would you say is a common element or feature between them that would provide an advantage over yourls, In other words, why in the #$*! would someone want to pay? lol

    Thanks!
    Rachel

    • Steven

      Hi Rachel,

      Honestly I don’t know why anyone would pay for link cloaking scripts, unless you didn’t know of this option (Yourls)… or want something that’s easier to integrate (like a WordPress plug-in).

      Otherwise, the only reason I can see why you would want to use a paid option would be because you need other stats (like referring keywords… for PPC campaign tracking purposes).

      All the best,
      Steven

      • http://www.jguiss.com/ Julien Guiss

        With a google Analytics plugin you can track all the trafic to your Yourls installation :)

  • http://www.newlee.info/astrology Grampz

    Thanks, I have been looking for a workable cloaking and tracking script. Does it provide advanced info such as referring url and search keywords?

    • Steven

      It does have stats like referring URLs and traffic location. Does not give you search keywords (as far as I know). I use Affiliate Prophet when I need that sort of information (like when I use PPC to a site).

  • Alex Aramen

    If you are cloaking because of Google then it is all for naught. Have you seen the new copy of Googles “Search Quality Rating Program”. Let me know I’ll send it to you. They actually visit your links and if they are not they same as your home url, for the most part, then you get assigned a spam code depending on the content of your site. It goes way deeper than this but this is it in practical terms.

    If you are cloaking because of affiliate sales then what you are saying would awesome.

    • Steven

      Hi Alex,

      Nope. I don’t cloak for Google… and I’m very aware of their policies. But thanks for the offer to send me their document.

      As I mentioned in Tim’s reply, my reasoning for using a link shortener are several, but the most obvious are:

      - to make nicer looking links
      - to hide affiliate links (particularly when affiliate IDs are exposed)
      - for use when I’m sending Auto Responder messages (many of the common link shorteners are not spam box friendly)
      - for tracking and testing purposes

      and several other reasons.

      All the best,
      Steven

  • Tim

    Hey Steven I was just wondering why people use shorteners like bit.ly or tinyurl or even yourls. Isn’t this similar to GoCodes? If SE’s are “on to it” by now won’t it be a matter of time that yourls gets had too?

    Also I used a shorter in the past that now redirects to some spam site.

    -Tim

    • Steven

      I use Shorteners for several reasons, but one of them is for easy tracking of links. Another is for “shortening”… particularly for social media sites. Yet another is for when I send out emails via an autoresponder to my many lists because long URLs look ugly, and because email spam filters do not like bit.ly and some others.

      One of the reasons I use a script on my own domain is because of the reasons you list above… (like being re-directed to spam sites). That’s not likely to happen if you’re the one who controls the script. :)

      /Steven

Steven