There are a few ways to setup your shortening service. You can host your own service or if you do not want the hassle of managing your own service, there are quite a number of services available that do it for you.
Set Up Your Own Service
1) Register a domain
2) Host your domain
3) Install the shortening appThere are a few very good solutions available such as Z.ips.me and Shorty. Most services require the hosts to support PHP scripting and MySQL database access. Z.ips.me needs support of PHP5 too. Installing these apps is easy. All you have to do is to provide information of your database such as name, location, username and password etc. They maintain logs and statistics for you too. Another excellent service is YOURLS.
The Easy (but not free) Way
Use a third party solution if you do not want to host your own service and get confused while all you wanted was to shorten your URLs. There are services such as Bit.ly and Awe.sm. They provide already hosted solutions to your shortening needs.
With Bit.ly all the hard work is done for you. They provide a hosted solution that is renowned and their analytics are quite great considering they provide both real-time and long-term reports. All you have to do is to register your domain, apply to Bit.ly and use a specific IP address that it provides to set the A-record of your short domain. You can start using the service right away after this. It has quite a few handy bookmarklet integrations for your browser.
For Mac users, CloudApp is a good option.
There are other options too, but it should be kept in mind that you may end up losing all your shortened links if the fly-by-night services go down.