My only experience of doing this was a 3d printer but it seemed to work well.

Basically, get one rail mounted square to the frame (clamp firmly and drill using a bush as Mike suggested) and then loose clamp the other rail and fit the gantry (or whatever the bearings are attached to). If anything moves as you slide the gantry up and down then somethings out of square and needs adjusting. When it's all sorted, clamp down properly and drill using a bush as before (with the gantry near the place you're drilling to stop it moving on the clamps).