We use shortening URL services like TinyURL, Bit.ly, su.pr, etc on daily basis. These services are great, but have you thought of creating something similar your own? Setting up such service on your own is fairly easy, and if you are using Wordpress it too comes with a plug-in that work seamlessly well.
YOURLS (Your Own URL Shortener) is what we’re talking about. It’s a free PHP script created by Lester Chan and Ozh Richard that allow you to create something similar to TinyURL and Bit.ly. We’ve installed and played around with it for a while, and here are our thoughts:
- Easy to install – If you’ve got no problem installing Wordpress, then setting YOURLS is a piece of cake.
- Customizable links – You can customize the links instead of the random characters that make no sense.
- Statistics – An admin page that allows you to manage and keep track of details like date of creation, IP, clicks, etc.
- Public/Private links- You control whether this service is available for public to use or yourself only.
- Bookmarklet – Easy bookmarklet to create your own short URL on the fly.
YOURLS also comes with developer API as well as Wordpress plugin. If you like the idea of owning a private url shortening services, please read on. We’ll cover a simple guide on how to setup YOURLS.
First and formost
Here are some things you’ll need before the installation:
- A domain – A short one would be perfect but it’s hard to get these days. If you are thinking of getting a really short domain name, we suggest you try your luck on country code top-level domains like .at, .lv, .ly, etc with domain.nr.
- PHP Supported account – YOURLS runs on PHP, so you will need to make sure the server (dedicated or shared hosting) supports PHP 4.3 and MYSQL 4.1 and above with
mod_rewriteenabled.
Read more about YOURLS requirements.
1. Download
Download the latest version of YOURLS. Unzip it and fire up your favorite text editor. We are about to do some configurations.
2. Configure
- Look for
includes/config-sample.php, rename it toincludes/config.phpand open up in editor. - Mandatory settings you’ll need to change are:
YOURLS_DB_USER,YOURLS_DB_PASS,YOURLS_DB_NAME,YOURLS_SITE. Last but not least, change your password forusernameandusername2. The rest of the settings are optional. We suggest you go through the entire thing, it’s pretty self-explanatory. Please drop us a comment if you have problem filling this, or check out the YOURLS configuration guide. - Create a database – Create a database with the name you’ve inserted for
YOURLS_DB_NAME. If your web hosting account provide you with cPanel, login and find "MySQL Database" under Databases column.

3. Upload
Upload all files and folders in the exact same structure to the root folder of your web hosting account. Your root folder name might varies from public_html, www, html, etc.

4. Install
We are almost done now. Fire up a browser, type in your domain name as url, follow by /admin/install.php. For example: http://yoursite.com/admin/install.php.
If everything is setup correctly, you’ll see these following messages with the link to your admin page at the end of the line.

5. Done!
Go on, login and start creating your very own short URL. Make sure you check out the Tools too, if you’d like to make a bookmarklet. Here’s a sample of how our YOURLS admin page looks like.

Hope it works for you, drop us a comment if you have any questions :-)
Related Contents |
Sponsors |
|
Posted by hongkiat in Tools , at 09.17.09
Tags: custom, domain, howto, short url, shortening |
|






















Comments
abdusfauzi September 17th, 2009
looks fun! but, i’m still searching for the need of having this service myself. i guess, not now. hehe.
ReplyDushan September 17th, 2009
nice post… I was wondering how these guy do the URL shorting you helped us
ReplyMelvin Foong September 17th, 2009
I wonder, if MyNIC will allow sodo.my. THAT would be fun.
Replynaz September 17th, 2009
this is what I dream for lately! thanks =)
ReplyPrince of Andalus September 17th, 2009
nice, great tutorial, i want to it soon
ReplySean O September 18th, 2009
YOURLS is a great way to “install” your own URL shortener. For those interested more in creating their own from scratch using PHP & MySQL, check out my recent article:
Replyhttp://sean-o.com/short-URL
Blaineblogger September 18th, 2009
Ok, that’s just cool. I’ll have to do it soon. Su.pr has a feature like this where you can get yourdomain.com/djd7f but I guess doing the above example you can get a keyword or two in.
ReplyDinesh September 19th, 2009
Same here
Replykahpeng September 20th, 2009
Nice tutorial hongkiat, I thought want to come up with the How-to post, but here you done a good job here. I haven’t upgrade and play around with YOURLS version 1.4 beta with more cool stats.
(Off-topic: Any1 interested to own WP.MY short domain ? =D Drop me an email with your offer @ http://scr.im/kp Thx!)
ReplyDave Chonurous September 21st, 2009
Great little tutorial. Check out this addictive game http://gumbota33.mybrute.com
ReplyMaulik Panchal September 21st, 2009
Nice Posting : )
Replykimutaku September 23rd, 2009
Thank you for your sharing,I like this.Spy DVR camera Watch
Replymyklikers.net September 27th, 2009
Nice one hongkiat. I been looking for this url shortener for a long time. Your post was resourcefull as always. love it!
ReplyJayce September 29th, 2009
Cool… Going to try it out. :)
ReplyChamteh September 29th, 2009
Just the one I was looking for. Made my job easy ;)
ReplyHoney October 2nd, 2009
Thanks you ^.^
Replyjason October 3rd, 2009
wanted to register yum.my… but someone got it already. :(
Replymaurice October 5th, 2009
Check my project smrls – it allows anyone to get a url shortener – not only the people that own a domain! You can check it on http://smrls.net/ – feedback is really appreciated! :)
ReplySaxaphone Lessons October 9th, 2009
Peferct. This is something we’ve been looking at.
Replymaurice October 18th, 2009
it can be done easier. go to http://smrls.net/, think about a name for your url shortener, try to register that.. and you are done. you can create as many as you like, making it possible to create a shortener per subject you like let me know what you think of it via twitter @smrls. thanks!
Replyfun games for kids October 19th, 2009
It looks like pretty easy to setup even for php beginner. Thanks for the tutorial. Great post!!
ReplyLing October 21st, 2009
Thank you! Was looking for a free script that does url shortening and this post helps! ^^
ReplyTwitterPimper October 23rd, 2009
Great article I have just put it on http://Okrati.me
ReplyThanks again…
opentube October 28th, 2009
interesting article! But, we need to be cautious of what we shorten URL. Some time down the line, if we decide to stop, then all the older URLs need to be replaced :)
ReplyNicolas Hoizey November 4th, 2009
I created another project on this topic: http://cas.im/ir/
Replyfafa November 16th, 2009
njvhvkLongines shop
ReplyTrackbacks