IT band

A tight IT band often manifests itself as pain on the side of the leg, usually near either the hip or the knee.  This is primarily caused by tight tendons caused by muscle imbalance in the hamstrings or quads, and additionally can be caused by high periods of stress in one's life (this can cause your body to tighten up while sleeping, exhibiting itself as tightness and pain upon waking).

Preventative

Hamstring and Quad strengthening: Try bodyweight squats to strengthen the hamstrings and quads, and stretch those areas as well.

Roll on a foam roller:  Lay on your side, with the foam roller under your hip and your hands underneath you for balance.  Slowly roll from the hip down to the knee and back up to the hip twice.  Then find the location where it hurts most, and keep the foam roller on that location, rolling back and forth with little motions (kind of like a violinist who wants to stay on just one string).  If it hurts, that means you're doing it right.

IT band stretches: See some of the more popular stretches here.

Tensor fascia latae stretch: (hug the knee)

This stretch lengthens the tensor fascia latae muscle which is found on the outside of the hip. The IT band is almost like a long tendon which extends from this muscle, down to the knee. The athlete sits on the floor with one leg out straight. The leg to be stretched is bent and the foot placed on the outside of the other knee as shown. They then use their hands to apply a pressure as if trying to pull the bent knee across the other one. Hold for 30 seconds and relax. Repeat 3 to 5 times.

Myrtl: in particular, Clams, Lateral Leg Raises, Donkey Kicks, Donkey Whips

Restorative

All of the above exercises, and:

Ice: ice the location