Bitly VS YOURLS
As of recently, I decided that using bitly was good, but I really wanted to have my own short URLs that I would use in posts and in Social Media. Bitly is good, but it really isn't that great when it comes to branding, so I began the search for a short URL that would work for me.
The search began on Domainr.com. Domainr shows you all the combinations of a given word beyond .com, .net and .org. When you search for a name, it gives you all the combinations, using different domain extensions, and that's how when I typed in "Koral", I got kor.al for my short domain. Pretty cool so far. After registering the short URL through Host.AL, as it was the only place that sold the .al domain cheaply enough, I then turned my attention to the actual service I'd be using to manage my short urls.
While I could use Bitly, I did some research on other services, and decided to use YOURLS, a self hosted URL shortening service. Bitly's only advantage over YOURLS is that it provides better click stats for paid customers (like for $995/mo on the enterprise plan) and that it is probably a little more reliable in the fact that there's redundancy. With a self hosted solution, usually small timer's like me don't go and get load balancing and a second server in case the first one fails. For a small private site like this, that's ok. Besides, I'm using Akeeba's standalone backup (Akeeba Solo) to back everything up.
Since I didn't need much in the way of hosting, I chose to use a virtual private server (VPS) to host the URL shortener on. At the time of this post, ChicagoVPS.net had a very nice sale on a 128MB VPS with 3GB of SSD Space for $12/year. That's way more than I needed for this, and since the price was right, I purchased and deployed it within an hour.
So, after buying the domain, I purchased the hosting, then went back to the domain and set the A-Record to the new VPS' IP address and set the www. subdomain to a cname for kor.al
Setting up the hosting isnt hard. I deployed using the Ubuntu 14.04LTS Server OS image. It only took two minutes for the server to come online, so I SSH'ed into it with puTTY.
First things first, make sure you are fully updated and upgraded.
# apt-get update && apt get upgrade -y
That will take about five minutes. Time for a coffee. When you get back to your computer, the cursor should be back at the command line waiting for the next command. We now install Memcached and a few other things needed for the YOURLS install:
# apt-get install memcached php5-gd php5-curl curl nano -y
After these install, we're ready for the YOURLS install itself.
You'll want to download the latest off of github, so in the command line, go to your www folder:
# cd /var/www
remove the index.html file:
# rm index.html
and download YOURLS:
Once it downloads, extract it:
# unzip master.zip
This will extract the files into a folder called YOURLS-master. you'll need to move them to the WWW folder you're currently in. This makes them accessible from the top domain (in my case, it would be at kor.al as opposed to kor.al/YOURLS-master as that's where everything extracted).
# mv YOURLS-master/* .
Make sure you get that period at the end of the above command! That tells the server to move the files to your current location. Now, you'll need to create the database.
# mysql -u root -p
you'll need to enter your root password to access MYSQL. Next, create the Database:
> CREATE DATABASE yourls;
where "yourls" is the name of your database. It will kick back "Query OK, 1 row completed" or something similar. hit ctrl-x to exit mysql.
Copy user/config-sample.php to user/config.php.
# cp user/cfg-sample.php user/config.php
Now you need to edit the config file.
# nano user.config.php
Edit the bolded lines:
/* This is a sample config file.
* Edit this file with your own settings and save it as "config.php"
* IMPORTANT: edit and save this file as plain ASCII text, using a text editor,$
* Notepad on Windows. Make sure there is no character before the opening <?php$
** MySQL settings - You can get this info from your web host
/** MySQL database username */
define( 'YOURLS_DB_USER', 'root' );
/** MySQL database password */
define( 'YOURLS_DB_PASS', 'rootpassword' );
/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'databasename' );
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port', eg. 'localho$
define( 'YOURLS_DB_HOST', 'localhost' );
/** MySQL tables prefix */
define( 'YOURLS_DB_PREFIX', 'prefix_' );
** Site options
/** YOURLS installation URL -- all lowercase and with no trailing slash.
** If you define it to "http://site.com", don't use "http://www.site.com" in y$
define( 'YOURLS_SITE', 'http://shrturl.here' );
/** Timezone GMT offset */
define( 'YOURLS_HOURS_OFFSET', -11 to 12 );
/** YOURLS language
** Change this setting to use a translation file for your language, instead of$
** That translation file (a .mo file) must be installed in the user/language d$
** See http://yourls.org/translations for more information */
define( 'YOURLS_LANG', 'EN' );
/** Allow multiple short URLs for a same long URL
** Set to true to have only one pair of shortURL/longURL (default YOURLS behav$
** Set to false to allow multiple short URLs pointing to the same long URL (bi$
define( 'YOURLS_UNIQUE_URLS', true );
/** Private means the Admin area will be protected with login/pass as defined b$
** Set to false for public usage (eg on a restricted intranet or for test setu$
** Read http://yourls.org/privatepublic for more details if you're unsure */
define( 'YOURLS_PRIVATE', true );
/** A random secret hash used to encrypt cookies. You don't have to remember it$
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
/** Username(s) and password(s) allowed to access the site. Passwords either in$
** YOURLS will auto encrypt plain text passwords in this file
** Read http://yourls.org/userpassword for more information */
$yourls_user_passwords = array(
'adminname' => 'adminspassword
/** Debug mode to output some internal information
** Default is false for live site. Enable when coding or before submitting a n$
define( 'YOURLS_DEBUG', false );
** URL Shortening settings
/** URL shortening method: 36 or 62 */
define( 'YOURLS_URL_CONVERT', 36 );
* 36: generates all lowercase keywords (ie: 13jkm)
* 62: generates mixed case keywords (ie: 13jKm or 13JKm)
* Stick to one setting. It's best not to change after you've started creating $
* Reserved keywords (so that generated URLs won't match them)
* Define here negative, unwanted or potentially misleading keywords.
$yourls_reserved_URL = array();
** Personal settings would go after here.
Now you just need to go to your admin page in your browser and setup the site:
login and you can begin using your new short url service!