Bottom line, remove distractions, create a task list with goals to achieve, and time box each effort. Check in on your list after each milestone, and make adjustments as you may find some tasks take a little longer than anticipated. Put your phone on silent, and/or change instant message (IM) statuses to say, "busy - on special assignment", or something equivalent. This might help deter someone from wanting to reach out and say hi.
Sounds simple enough, but you will find you have to adapt to your surroundings and find what works best for you. For example, I work from home quite a bit, but on occasion I need to go into the work-place which, for me, is designed to be an open-floor concept. The open-floor concept means desks have no walls or partitions, meeting rooms are separated with glass, and there are common seating areas where people can congregate. Goes without saying, but there are plenty of distractions being able to see into conference rooms, watch people walk down the hall, or even listen in on a conference call of the person sitting three feet from me, eye-to-eye!
Without the comforts of being isolated at home, what can we do to minimize distractions? Again, find what works for you in your setting, but here's what I do when at the open-floor office: 1) use noise cancelling headphones, and play 'soothing sounds/music' into the ear pieces to minimize the noise around me, 2) sit with my back to the hall and conference rooms, or 3) reserve a conference room to work in if the distractions/noise are too great. The keys are, adapt, improvise, and remember to have a list of what you want to accomplish!
Hope this helps give you some ideas!
Make it a great day!