Personally, I like silence (or as close as I can get) when writing new material. I want to be able to be totally lost in the story. I don't like distractions and I need to be alone. I’m one of those DON’T LOOK AT IT until it’s finished kind of people, and even if I think someone’s looking at me I can’t write.
When I’m editing, particularly a scene I’ve read over before, I like music. Especially music I associate with the story. For example, playing “The Earth Moved” while editing the end of Acapella Angels with the storm. Giving your stories a soundtrack is a ton of fun. I’ve also tried writing with good “studying music,” mostly classical stuff. Just search for it on youtube and they’ll give you some good long mixes. If it helps you, it’s a double bonus. Not only are you getting good writing done, you also get to feel super high class and fancy.
It's also important to note that the writing should come first. Spending too much time creating your perfect environment can lead to prolonged procrastination.