Even if you're innocent - that is you don't think you were speeding, weaving lanes, or running stop signs, those flashing lights behind you will up your adrenaline level. It's normal. So the first thing to do is take a deep breath, release it slowly, then look for a safe place to pull over. That can be the side of the road or a close (within visual distance) parking area. Put your turn signals or flashers on then pull over as far as possible.
Put your car in park. When an officer stops you he is looking for the flash of your backup lights to signal that you have put your car in park. No flash - no confidence. You don't have to turn your car off unless told, but it can't hurt. Even if it's cold outside, a few moments without the heater isn't going to harm you and you've clearly signaled no intent to drive off. If it's raining, you should still roll down the window a bit. Enough at least to be able to see out (and the officer to see in). It's just water. So, roll down the driver's side window and place your hands on the top of the steering wheel.
Some folk advocate you should put your hands outside the car. I don't recommend that for the simple reason it is an unusual action and, well, officers don't like unusual actions. It tells me I'm now dealing with someone who has been pulled over before under less than routine circumstances and that will increase my awareness. Just keep your hands on the top of the steering wheel.
You can put your wallet or IDs on the dash if doing so doesn't display what might be construed as unusual behavior. If you have to reach into the glove box or turn around in your seat to get your wallet or purse, just leave it there for now.
All the above has happened before the officer leaves his vehicle. Very likely the officer will not exit their vehicle for a few moments as they have to radio in their location, your license plate ID, and a vehicle description. The purpose of the vehicle description is to confirm the license belongs to that vehicle. They will also radio in how many people they see in the car - assuming they can see in through the tinted windows. They may, or may not, radio in the probable cause for the stop. They may, or may not, wait for a response from dispatch on the license plate check. All of this is for the officer's protection. If something goes wrong, dispatch will have to know where to send help and what vehicle responding officers will have to track down.
Now comes the interaction between you and the officer. First impressions, yes? Here's where it can get icky. You see, the officer's primary concern is his or her safety. That's right, they aren't at all concerned about which code violation needs to be written on the ticket or whether you are black, white, Hispanic, Asian, or extra-terrestrial - they just want to go home at the end of their shift.
The officer may approach from the driver's side or the passenger side depending on circumstances. If there are two officers, each will take a side with one staying further back. You'll see that through your rear-view mirrors so there is no reason for you to be surprised. The may put one of their hands on your car as they approach. That leaves a print confirming, definitely, it was your car that was stopped should something go awry. A good officer will stand just slightly back from the driver's window and not directly in front of it. Again, for their safety. From this position, they can see you directly and can see through the rear-view mirror. There's no need to turn around and try to see the officer.
Now the scene is set for the most important part of the traffic stop - communication. The first words out of your mouth should be something to the effect of: "Hello Officer, in the interest of our safety I have no weapons in the vehicle." or "Hello Officer, in the interest of our safety I have a legally registered weapon in (holster, glove compartment, trunk, or wherever it is)."
Here's the most important advice I can give you: If the officer tells you to do something (get out of the car, turn off the engine, etc.) follow the directions AND make your statement be the first words out of your mouth. Do what you're directed and make sure you say those words.
I highlighted the words not that you should emphasize them but that you recognize they serve a very important purpose. First, the use of the word "officer" says you recognize their authority. It's a polite form of submissiveness. Use it. Second, the acknowledgement that there is or is not a weapon and the concurrent use of the words "our safety" states that your concerns are the same as theirs: safety.
You have now set the stage for what should prove to be a rather uneventful traffic stop.