There are so many variables it's hard to give a definitive answer, but if you get the basics right you will normally get some pretty good shots. This is what I do:
- Lowest ISO setting (noise is bad)
- Shutter Priority
- Manual Focus
- Tripod / solid platform for camera
- Some way to trigger shutter without movement (I use a remote)
I focus manually on the rough area where the fireworks are going to be, the easy option is to pick something on the ground roughly the same distance away, then re-compose your camera to where the fireworks are going to be. The length you keep the shutter open depends on the size and frequency of the fireworks, but for reasonable displays between 5-10 seconds seems to work well for me. For this display, I checked the first shot to make sure it was in focus, then just played with the shutter speeds after each shot for different effects. I wanted a couple of explosions in each shot, not a really long exposure with loads layered, and it seemed to work well.
135mm, 5 seconds (display was about a mile away)
I read a book that suggested using f11-f16 to make sure you have a good range covered in terms of focus, which makes sense, but that also requires a lengthy shutter speed (potentially 30s or more). But I actually got better results shooting wide open (f2.8) and keeping the shutter speeds below 10s. As always though it's what works for you and what you want out of it.