Tips and Tricks Site

Recent Posts

Thursday, 6 November 2014

Create Your Own Link Shortening site

Link shortening sites are use to shorten your long links into small links. There are many advantages of a shortened links. I’m not going to discuss that What are the advantages of a shortened link and why you should use them.
There are many URL shortening sites available in the internet these days, but creating your own means you will be the owner of the site. You will not need to rely on other sites. No one except you will be able to delete your links.
In this tutorial, I’ll show you a step-by-step procedure of how you can create your own URL shortener with YOURLS (A free and open source software to create your own URL shortening service).

Things You Need:

  •  A web server with mode-rewrite enabled and at least It should run PHP 5.2 and MySQL 4.1
  • A small domain name. For URL shortening sites, you should use top-level domain (TLD) or a Country code top-level-domain (ccLTD). They would cost you from $8 to $100 . You can use domai.nr to find a small domain name.

Settings

First go here and download the latest yourls package. After downloading extract it on your PC.
Database Name - Create Your Own Link Shortening SiteLogin to your website’s cPanel, scroll down to Databases section and click on MySQL Databases. Then enter the name of database and click on Create Database.
After you created a Database, scroll down and create a user by entering a username and password. Then we have to add that user into the specific database which we created.
To do that, scroll down a little bit more until you see Add User To Database and choose the user which you want to add to the specific database. I created the database techooid, so I’ll choose that and click on Add and It will ask you for privileges. I will give all the privileges.
I am using Hostwinds as my hosting. The upper settings may be vary according to your hosting provider but you can search on Google about it.
Database Config - Create your own links shortening siteNow open the folder where you extracted that .zip folder. Go to user folder (available in the extracted files) and you’ll find config-sample.php , Open it with any text editor like Notepad. You’ll see some lines like database_name, database_password etc. Replace all those with your database information.
Those were the MySQL settings, scroll down in that text file and you’ll see Site options. Enter the site address in which you’ll use YOURLS. If you’re installing YOURLS in a subdomain. Just enter the subdomain like http://subdomain.maindomian.com
There is also a line in which you have to enter a  username and it’s password. Don’t enter your database username and password in that field. That option is to create a username and password through which you’ll log in to your YOURLS account. There are many other options too, you can go here to know for what purpose they are used.
After you’ve entered all the details, Save it as config.php.

Uploading

After you’ve completed all the steps which were mentioned above. It’s the time to upload your files on your web server. To upload your files, you might need to use FTP client, command line or any other method. I used FireFTP (It is a Mozilla Firefox addon which works as a FTP).

Installing

Install - Create Your Own Link Shortener

Now it is the time to install YOURLS on your website. Go to the site where you installed YOURLS and add /admin/index.php next to it . Then click on the Install YOURLS button.
If everything goes right, then you’ll see 4-5 check signs in green color.
Success - Create Your Own Link shortener

Using

Now YOURLS is installed on your website. Go to site.com/admin and log in with the username and password you putted in the config.php file. YOURLS have a nice and easy to use interface. You can shorten your links, delete links, install plugins, see the stats of the link and much more. Statistics of a link can be seen by adding a (plus sign) at the end of shortened link.
adminpanel

If you’re thinking to make your link shortening service for public and not only for yourself. There is a option for this too in the config.php file. If you’ve kept it as public and try to open your website, you’ll see something like the below pictureIndex - Create Your own Link Shortener

Renaming - Create your own link shortenerTo fix this, go to your cPanel then File Manager (The place where you’ve uploaded that all files). There will be a file named as sample-public-front-page.txt , You have to rename it to index.php

As you’ll rename it, again open your website and you’ll see your URL shortener.
There are also a lot of plugins available for YOURLS. See the plugin list. Almost every plugin show you that how to install it. Now you can track your links and you don’t need to rely on other link shortener.

Integration with WordPress

In this section I’ll show you how you can integrate your link shortener with your WordPress website. Integrating with WordPress will help you to get the links of your post without opening your YOURLS website and manually shrinking it. You’ll able to get the short links of your posts right from WordPress websites.
Download plugin - Create your own link shortenerGo here and download the plugin. After downloading extract it and upload the yourls-link-creator in /wp-content/plugins
You can upload through FTP or directly the .zip file and then extracting through your cPanel. It depends on you which method you choose.


Plugins - Create Your Own link shortenerAfter you’ve uploaded the extracted file,log in to your WordPress website and go to Plugins and activate the YOURLS plugin.
After you’ll activate the plugin, You will see Settings written instead of Delete. Click on the settings.

Settings - Create your own link shortener

Then you’ll see a page with some blank fields. In the first field (YOURLS custom URL). Enter your website address where you have installed YOURLS. Don’t enter http://, just enter the address like techooid.com

In the YOURLS API Signature key, paste your API key. You can get your API key by logging in to the Admin panel of YOURLS (the site where you installed it) and then go to tools. There you’ll see your secret signature token. Copy that and paste into that field.
Check/uncheck the boxes according to your needs and click on Save Changes.

Now you have successfully integrated YOURLS with your WordPress website. Go to the posts in WordPress and click on any post and you’ll see YOURLS Shortlink at the top right side of the page.

Do you created your own URL shortener? We’ll love to see, share through comments ;)

0 comments:

Post a Comment

Say About Us.. :)