The exercises mentioned on here are good for rehabbing the hamstring, but it might be a bit much for them while they are actively hurting. A couple of things I haven't seen mentioned on here yet:
Stretch your hip flexors. 30 seconds of stretching on each hip flexor a couple of times a day can work wonders for this issue. Tight hip flexors (specifically the Iliopsoas) tilt your pelvis forward (anteriorly) which puts your hamstrings under constant strain, especially on the proximal end. If you sit a lot you probably already had tight hip flexors and then when you over do your training it tends to tighten up your hip flexors even more. This I suspect is the root cause for many of us getting this issue. If your hamstring or hamstring attachment is hurting just lying in bed it's likely your pelvis is tilted forward even in this position. Try laying on your stomach and putting a pillow under your stomach to force your pelvis into more of a neutral position and see if that doesn't provide some temporary relief for your hamstring. You can try sleeping like this, for at least part of the night, to see if it gives your hamstrings enough of a break to start healing.
Someone else already mentioned strengthening the glutes, not only does this help take some of the load away from the hamstrings while standing/walking/running etc, but when the glutes flex it tilts the pelvis into a more neutral position which again helps take tension off of the hamstrings.
In summary: stretch the hip flexors, strengthen the glutes.