Every author has his own way of writing. Some need a fixed environment and fixed writing times. Others need to do extensive outlining and characterization. Some like the freedom of letting the story and characters carry them where they will. None of these approaches is wrong or right. They are simply what works for that author. Below I will describe my methods and tools. Feel free to try them to create your own work. But do not fall into the trap of thinking it is the only or the best way. For that, you must match yourself to your environment and see what works best for you.
I have written in restaurants, in cars, on a bus. I have worked in a library, a busy office and currently in a quiet mountaintop retreat center. One of my writing requirements is to be able to capture an idea anywhere I am and to be able to flesh it out when the time is available.
Just as I have worked in a variety of workplaces, I also have worked at a variety of work times. Early morning, late evening, for long stretches and during short breaks. I try to remain flexible in how I work. The challenge is to be able to bring my mind to focus on the story when the time and ideas are present. To capture the thoughts before they are lost.
Distractions are a part of life. However, learning to focus past distractions to get the work done is one thing I learned as a child, doing my homework on a bus with as many as seventy other children providing distractions every moment of the hour-long trip.
Creativity is putting your imagination to work, and it's produced the most extraordinary results in human culture.