1. Place the foam roller underneath your leg
2. Bend your opposite leg and use it as a lever to move back and forth
3. Turn your foot inwards to get the inside of the hamstring
4. Turn your foot outwards to get the outside of the hamstring

Maintaining three points of contact while you foam roll your hamstrings allows you to control how much force you put into the foam roller. You can roll the full length of the hamstring or break into the top half and the bottom half if that is easier for you.